Getting started with any programming language like JAVA should be purposeful.
we must understand the features and power of the programming language to develop a deep interest in it.
James Gosling and his team was the intelligent mind behind the Java
it is developed after the C and C++ around 1991.
We can consider Java a complete package for software developers to play with it.
Java is currently worldwide most used programming language as the biggest tech giants like Amazon, Google, TCS, have a huge percentage of code in Java.
Java is power-packed with ample of features, Here are some of the most important features of Java Programming Language:
Features Of Java Programming Language
Java was designed for professional developers to learn and use easily. If you are aware of basic programming principles, then Java is not a hard nut to crack.
One of the main reason why java is simple because there is no need to remove the unreferenced objects because Java Garbage collection is present which automatically detect unused Objects.
Java achieves security by confining Java Programs to Java Execution Environment.
JEE do not allow Java programs to access other parts of the computer system.
Compiler of Java Converts the Java Code into Bytecode also known as .class file, which is machine independent and only understand by the Java Virtual Machine.
Portable code must run on variety of operating systems , CPU’s , browsers .
When Java program is compiled, a Bytecode is generated, this bytecode can be executed on any platform using JVM as discussed above.
Java provides a clean, usable, pragmatic approach to objects, it was designed on the principle that “Everything under the sun is Object.”
the sun is the parent company of Java. But Java is not purely Object-Oriented Language, the complete object-oriented language is Smalltalk
Robustness of the program is reliable execution on a variety of systems , to better understand this , consider one of the main reasons for program failure is memory management,
In C/C++ programmer, must manually allocate and free dynamic memory, there are cases programmers forgot to free up the dynamic memory.
Java virtually solves this problem as unused objects are garbage collected automatically.
The central issue for Java Designers was that of code longevity and portability.
One of the main problems for programmers was that there was no guarantee that the program running perfectly fine today will run tomorrow
because of the system upgrades, processor upgrades or changes in core system resources.
Java Designers made several hard decisions and designed Java Virtual Machine to solve this Problem. Their goal was “write once, run anywhere, any time, forever “.
Java is designed for distributed environment because it handles TCP/IP protocol.
It is very much useful in building large scale distributed computing based applications.
Java also supports Remote Method Invocation. This feature enables a program to invoke methods across a network.
Java Program Compilation
Java program compilation converts java program file to highly optimized class file which is called bytecode which is platform-independent and can be used in any of the platforms with the help of JVM[Java virtual machine].
Java Program Execution
Java program execution is completed with the help of the following tools
When user compile the Java Program, It converts into the bytecode (Of course if it has no compile-time error)
But in run time the following steps performed
classloader are the part of JVM.
As the name suggest Classloader loads the class during the runtime for the JVM. Due to classloader JVM does not need to worry about the files system.
One thing you need to know is Java class are not loaded into the memory at one time, they are loaded whenever class is required by the application.
According to the Oracle,”The bytecode verifier acts as a sort of gatekeeper”.
Bytecode Verifier traverse the Bytecode and restrict objects for illegal access of other part of the system.
It read the bytecode instructions and execute it line by line.
Java program Execution Flow:
Java Virtual Machine ( JVM)
JVM is called an abstract virtual machine because it does not exist physically, it is a kind of specification that provides a secure runtime environment to execute the bytecode generated through the compiler.
JVM actually invokes the main( ) method present in the Java program.
JVM is a part of the JRE(Java Runtime Environment).
Java applications are called WORA (Write Once Run Anywhere).
This means a programmer can develop Java code on one system and can expect it to run on any other Java-enabled system without any adjustment.
This is all possible because of Java Virtual Machine.
Today, JVMs are available for many different types of hardware that’s why Java is machine independent language.
JVM performs the following operations
- Loads code
- Verifies code
- Executes code
- Provides runtime environment
Java Runtime Environment (JRE)
JRE stands for “Java Runtime Environment” and sometime also be written as “Java RTE.”
JRE is a part of JDK
The Java Runtime Environment provides the minimum requirements for executing a Java application; it consists of the Java Virtual Machine (JVM), core classes, and supporting files.
- A specification where the working of Java Virtual Machine is specified. But implementation provider is independent to choose the algorithm. Its implementation has been provided by Sun and other companies.
- An implementation is a computer program that meets the requirements of the JVM specification
- Runtime Instance Whenever you write java command on the command prompt to run the java class, an instance of JVM is created.
Java Development Kit(JDK)
Java Development Kit (in short JDK) is Kit which provides the environment to develop and execute.
The JDK contains a private Java Virtual Machine (JVM), interpreter/loader, a compiler (javac), an archiver (jar), a documentation generator (Javadoc), etc. to complete the development of a Java Application.