Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the JRE and JVM? [duplicate]

Tags:

java

jvm

People also ask

What is the difference between JRE and JVM?

JRE identifies all the helpful class libraries needed for execution, while JVM is a subclass of JRE that decodes the bytecode into machine language and other minor tasks. JVM and JRE do not participate in development processes like debugging and compiling; JDK is used for them.

What is the difference between the JRE and the JDK?

JDK(Java Development Kit) is used to develop Java applications. JDK also contains numerous development tools like compilers, debuggers, etc. JRE(Java Runtime Environment) is the implementation of JVM(Java Virtual Machine) and it is specially designed to execute Java programs.

What is the difference between JDK JRE and JVM stack overflow?

JDK - Compiles java to ByteCode. Consists of debuggers, Compilers etc. JVM - Executes the byte code. JVM is the one which makes java platform independent.

What are the purposes of JDK JRE and JVM?

JDK is for development purpose whereas JRE is for running the java programs. JDK and JRE both contains JVM so that we can run our java program. JVM is the heart of java programming language and provides platform independence.


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.

JRE = JVM + Java Packages Classes (like util, math, lang, awt, swing etc) + runtime libraries.

If you want to run any Java program, you need to have JRE installed in the system.

JRE is the box and JVM is the content of the box.

In simple words JRE = JVM + rt.jar

where rt.jar contains lang, util, awt, swing, math etc. libraries or compiled .class files used to run our program.

Learn more about difference between JVM and JRE- CLICK HERE


The JRE is the environment within which the virtual machine runs.

JRE - JAVA Runtime Environment

JVM - JAVA Virtual Machine

JRE is the container, JVM is the content.


First of all JDK contains JRE+development tools, JRE contains JVM+class libraries, where JVM contains (class loader & byte code verifier) and the Execution engine (interpreter & JIT).

The compiler will convert the source code into intermediate byte codes. Where this byte codes is given to JVM for execution, the class loader in the JVM will load the byte codes and does linking with class libraries provided by the JRE.

Then the code will be given to the execution engine in the JVM which interprets the unrepeated code and compiles the repeated code (for example loops) finally converting into machine code (object code). Then it will give the machine code to the microprocessor for execution.


In layman terms:-

JDK = JRE + Development/debugging tools, where JDK is our complete package to work with Java, from creating compiling till running it.On the other hand JRE is just of running of code(Byte Code).

Note:- Whether we are installing JDK or JRE, JVM would come bundled with both the packages and JVM is the part where JIT compiler converts the byte code into the machine specific code.

JVM is Java Virtual Machine -- the JVM actually runs Java bytecode.
JDK is Java Developer Kit -- the JDK is what you need to compile Java source code.
JRE is Java Runtime Environment -- is what you need to run a Java program and contains a JVM, among other things.

The Simple answer to this question is JRE is the super-set of JVM.

That is, the code which is compiled with java compiler(javac) produces the byte-code(.class files). jre which is the subset of jdk contains the required libraries along with jvm. jvm runs the byte-code and produces machine code that is in the machine readable form with the support of libraries required for that code.

To see the configuration of jvm go to : C:\Program Files\Java\jre7\lib\i386\jvm.cfg
This file contains the List of JVMs that can be used as an option to java, javac, etc.