Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995.
It is intended to let application “write once, run anywhere” (WORA), means code that run one machine/platform does not need to be recompiled to run on another.
It should be ‘Simple’ Object oriented and familiar
It should be robust and secure
It should be architecture neutral and portable
It should be executed with high performance
It should be interpreted, threaded and dynamics
The Java compiler is actually divided into two parts
1. Java Compiler
Java compiler is use to compile java programs i.e. file with extension “.java”
Java compiler takes .java file as input and produce .class file as output.
This .class file is platform neutral.
2. Now the JVM comes.
JVM stands for Java Virtual Machine.
JVM loads the class files and either interprets the bytecode or just-in-time compiles it to machine code and then possibly optimizes it using dynamic compilation.
Just-in-time Compiler (JIT)
JIT is the part of the Java Virtual Machine (JVM) that is used to increase the speed whenever the byte code is converted into machine code. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.
JVM is different for different machines.
You can consider the following way example to understand.
Suppose there is a building with ground and the first floor. The compiler is sitting in ground floor which welcomes or accepts the .java file and compiles it to .class file (byte code).
Now this byte code goes to the JVM that is on the first floor where the JVM do its work.
JRE stands for Java Runtime Environment. JRE contains JVM plus set of classes and interfaces which are loaded to create the environment i.e. the Java Runtime Environment.
JDK stands for Java Development Kit. JDK contains JRE along with various development tools like Java libraries, Java source compilers, Java debuggers, bundling and deployment tools.
Now here question arises that what is the overall picture or functionality of JDK, JVM, and JRE?
Answer to this question is the following figure. Now it’s the time to complete the figure.
Lets see how to set classpath and why there is a need to set classpath.
Suppose you are working on a java project using notepad or without using any IDE then to make the additional necessary jar files available to your project, you need to set each jar file by giving full path of the jar file in the classpath.
You can define your all the jar file once and no need to give classpath every time you start command prompt , this can be done as follows:
Right click on my computer > properties > advanced system settings >Environment variables >
Click on “New” below user variables.
Variable name: classpath
Variable value: specify complete path like C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar;.
Now you will see a new variable with name classpath and in value the specified path of jar file with name
If you wan to add another jar , for this click edit > add semicolon <;> then path of other jar.