difference between JDK and JVM?

difference between JVM and JRE?

Answered by Manish Kumar 

             profile picture


Java Developer Kit have all the tools needed to develop the Java programs, and then JRE to run the programs. The tools in JDK include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc. The Compiler in JDK converts java code into byte code. Then java application opens JRE, loads the class and invokes its main method. JDK is needed to write and compiles the program and for running the program JRE is used. 

Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system
The Java Virtual Machine provides a platform-independent way of executing code; That mean compile once in any machine and run it any where(any machine).


After compiling a Java file, '.class' is generated as output whic contains java byte codes which are only understandable by JVM. JVM just interprets the byte code into the machine code, and responsible for all the things like garbage collection, array bounds checking etc. JVMs are available for many hardware and software platforms. JVM, JRE and JDK are platform dependent because configuration of each OS differs. But, Java is platform independent.

The JVM performs following main tasks:

1. Loads code
2. Verifies code
3. Executes code
4. Provides runtime environment