JDK – Java Development Kit
Java Developer Kit contains tools needed to develop the Java programs + JRE to run the programs.
Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.
To write your own programs, and to compile the programs. For running java programs, JRE is sufficient. JRE is targeted for execution of Java files i.e. JRE = JVM + Java Packages Classes(like util, math, lang)+runtime libraries.
JDK is mainly targeted for java development. i.e. you can create a Java file (with the help of Java packages), compile a Java file and run a java file.
Java Runtime Environment
Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. 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; programmers can concentrate on writing software, without having to be concerned with how or where it will run. But, note that JVM itself is not a platform independent. It only helps Java to be executed on the platform-independent way. When JVM has to interpret the byte codes to machine language, then it has to use some native or operating system specific language to interact with the system. One has to be very clear on platform independent concept. Even there are many JVMs written on Java, however hey too have little bit of code specific to the operating systems.
JVM (Java Virtual Machine)
When a Java file is compiled, output is not a .class’ file. ‘.class’ file consists of Java byte codes which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent.
The JVM is called “virtual” because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and operating system is a cornerstone of the write-once run-anywhere value of Java programs.
There are different JVM implementations are there. These may differ in things like performance, reliability, speed, etc. These implementations will differ in those areas where Java specification doesn’t mention how to implement the features, like how the garbage collection process works is JVM dependent, Java spec doesn’t define any specific way to do this.
Please refer to the article to learn more about Java Virtual Machine.
References:
http://www.javatpoint.com/difference-between-jdk-jre-and-jvm
http://javarevisited.blogspot.com/2011/12/jre-jvm-jdk-jit-in-java-programming.html