What is the difference between JVM, JDK, JRE & OpenJDK?

Viewed 407820

What is the difference between JVM, JDK, JRE & OpenJDK?

I was programming in Java and I encountered these phrases, what are the differences among them?

22 Answers

In summary:

  • JRE = JVM + Java Packages (like util, math, lang, awt, swing etc) + runtime libraries
  • JDK = JRE + Development/debugging tools

If you want to develop in java, you need the JDK, but if you just want run java, you need the JRE.

  1. Developers develop using JDK, and first we write .java source code
  2. Developers debug the code and compile the code into .class bytecode executable files in JRE
  3. The executable files are executed by JVM, translating the bytecode into native machine code which machines can execute

enter image description here

Here is they relations:

enter image description here

Reference:
Java JDK, JRE and JVM

Simple image to illustrate JDK, JRE, JDK. JDK, JRE, JVM

JDK In general this will be installed only in development setups like in developers, QA systems in real-time at corporate companies. Original code which is running in servers will not have JDK.

JRE is a part of JDK and independently too installable in servers. In real-time servers which serving user requests will have only JRE installed and code developed by developers (in *.class format)

JVM Developer developed code > tested and executed in development machines. Execution phase require a medium for Java.

.class files are not native code (code which understands by cpu). To achieve WORA (Write Once Run Anywhere) concept can't be achieved if .java file is directly converted to native code.

Native code differs from OS to OS. So, Java created a intermediate file called .class and magical program called "JVM". Its JVM's duty to convert .class into native code.

JVM is abbreviated as Java Virtual Machine, JVM is the main component of java architecture. JVM is written in C programming language. Java compiler produce the byte code for JVM. JVM reading the byte code verifying the byte code and linking the code with the ibrary.

JRE is abbreviated as Java Runtime Environment. it is provide environment at runtime. It is physically exist. It contain JVM + set of libraries(jar) +other files.

JDK is abbreviated as Java Development Kit . it is develop java applications. And also Debugging and monitoring java applications . JDK contain JRE +development tools(javac,java)

OpenJDK OpenJDK is an open source version of sun JDK. Oracle JDK is Sun's official JDK.

JDK - Tools like javac used to compile *.java files to *.class bytecode files (basically develop Java programs)

JRE - Tools to run *.jar files (basically run Java programs)

JVM - Tools to compile *.class files to executable machine code (run all Java bytecode)

OpenJDK is just a distribution of the Java JDK.

Related