The JRE is the Java Runtime Environment. It is a package of everything necessary to run a compiled Java program, including the Java Virtual Machine (JVM), the Java Class Library, the java
command, and other infrastructure. However, it cannot be used to create new programs.
The JDK is the Java Development Kit, the full-featured SDK for Java. It has everything the JRE has, but also the compiler (javac
) and tools (like javadoc
and jdb
). It is capable of creating and compiling programs.
Usually, if you only care about running Java programs on computer you will only install the JRE. It's all you need. On the other hand, if you are planning to do some Java programming, you need to install the JDK instead.
Sometimes, even if you are not planning to do any Java development on a computer, you still need the JDK installed. For example, if you are deploying a web application with JSP, you are technically just running Java programs inside the application server. Why would you need the JDK then? Because the application server will convert JSP into Java servlets and needs to use the JDK to compile the servlets. I am sure that there are more examples.
JRE = Java Runtime Environment - what you need to run programs/software that require Java or use libraries written in Java. For example, OpenOffice requires the Java Runtime Environment
JDK/Java SDK = Java Development Kit/Java Software Development Kit - what you need to write programs that require Java or use libraries written in Java. For example, if you were to write your own word-processing tool in Java.
java
comes with the JRE because it launches the VM (virtual machine). It can take in class
files which are files that have been compiled using the JDK.
The JDK comes with javac
because that's what you need to compile your .java
files into .class
files that can then run on the JRE.
Best Answer
JVM
The Java Virtual Machine (JVM) is the virtual machine that runs the Java bytecodes. The JVM doesn't understand Java source code; that's why you need compile your
*.java
files to obtain*.class
files that contain the bytecodes understood by the JVM. It's also the entity that allows Java to be a "portable language" (write once, run anywhere). Indeed, there are specific implementations of the JVM for different systems (Windows, Linux, macOS, see the Wikipedia list), the aim is that with the same bytecodes they all give the same results.JDK and JRE
To explain the difference between JDK and JRE, the best is to read the Oracle documentation and consult the diagram:
Note that Oracle is not the only one to provide JDKs.
OpenJDK
OpenJDK is an open-source implementation of the JDK and the base for the Oracle JDK. There is almost no difference between the Oracle JDK and the OpenJDK.
The differences are stated in this blog:
Update for JDK 11
An article from Donald Smith try to disambiguate the difference between Oracle JDK and Oracle's OpenJDK : https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later
As mentioned in comments by @Alan Evangelista, Java Web Start has been deprecated by Oracle in Java SE 9 and removed in Java SE 11.