Understanding JDK-JRE & JVM- To Understanding difference between JDK,JRE and JVM is very very important in java for interviews
JDK: Java Development kit
JRE: Java Runtime Environment
JVM: Java Virtual Machine
Understanding JDK-JRE & JVM
What Is JDK ?
JDK stands for Java Development Kit and is a bundle of software that we can use to develop Java based applications.
It includes the JRE, set of library classes, Java compiler,jar and additional files needed to write Java applications.
What Is JRE ?
JRE is an acronym for Java Runtime Environment
It contains a JVM along with java classes/packages and set of runtime libraries.
So the JVM , while running a java program uses the classes and other libraries supplied by JRE.
If we do not want to write a java program , and we just want to run it then we only need a JRE
Q- Can I compile a java application if I have a JRE ?
No, JRE can only be used to run a Java application . It doesn’t contain the javac tool which is used for compilation
What Is JVM ?
JVM is an abstract machine that can execute precompiled java programs.
In simple terms it is the code execution component of java
It is designed for each platform(OS+CPU) supported by java and this means that every platform will have a different version of JVM
Q-Why JVM is called a virtual machine ?
JVM is called virtual machine because it is a software layer but it behaves as if it is a complete machine(platform). That is all the tasks which are done by a machine while running a program in other languages like C , are actually done by JVM in java.
For example: Starting the execution by calling main( ), Allocating Memory for the program,Memory cleanup etc
Q-What JVM Contains?
Apart from garbage collector and other important tools , the JVM contains 2 translators:
#JITC (Just In Time Compiler)