What is the difference between the JRE and JVM? [duplicate]
I think the JVM is similar to the .NET Framework, correct? Then what is the JRE? What is the difference between the JRE and JVM?
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.
The JRE includes the JVM, which is what actually interprets the byte code and runs your program. To do this the JVM uses libraries and other files provided by the JRE.
I believe you would say that the JRE is like the .NET Framework, while the JVM is like the .NET CLR. There are probably some important differences here I am not aware of though.
The JVM is the process that runs the Java code, and the JRE are all files distributed to form the "environment" in which the JVM runs.
JRE is an environment, in order to execute any Java program locally.
JVM is where it's responsible for converting the Bytecode into machine specific code and makes java program write-once-run-anywhere.
Java Virtual Machine (JVM) is an abstract virtual machine (basically, a program) that resides on your computer and provides a runtime environment for the Java bytecode (you program code after compilation) to get executed.
JVM analyze the bytecode, interprets it, and execute the same bytecode to display the output.
The basic function of JVM is to execute the compiled .class files (i.e. the bytecode) and generate an output. Do note, each operating system has a different JVM, but the generated bytecode output is the same across all operating systems. This means that the bytecode generated on Windows OS can also run on Linux OS and vice-versa, thus making Java as a platform independent language.
So, we can say that the JVM performs the following operations:
- Loading of the required .class and jar files
- Assigning references and verification of the code
- Execution of the code
- Provides a runtime environment for the Java bytecode
JRE (Java Runtime Environment), is JVM combined with the development tools needed to develop JVM compatible programs.
Check out the article to learn more about JVM.
JRE and JVM is part of JDK. jdk=jre(contains JVM)+Development tools.
JVM is specification and the name of JVM Implementaion is Hotspot or others, Implemented by different organizations.
According to Wikipedia:
The JVM, which is the instance of the 'JRE' (Java Runtime Environment), comes into action when a Java program is executed. When execution is complete, this instance is garbage collected. JIT is the part of the JVM that is used to speed up the execution time. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.
JVM - java virtual machine is a specification for a run-time environment to execute byte code. JRE - java runtime environment is the implementation of jvm JDK - java developement kit, it's JRE + developement tools.
JRE has all the class libraries can support java application. When a java application is about to execute JRE will create JVM instance, which will actually runs the java application.
精彩评论