Java JRE 和 JVM 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2812549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 13:08:41  来源:igfitidea点击:

What is the difference between the JRE and JVM?

jvmjava

提问by

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?

我认为 JVM 类似于 .NET Framework,对吗?那么什么是JRE?JRE 和 JVM 有什么区别?

采纳答案by Will Marcouiller

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

JRE 是虚拟机运行的环境。

JRE - JAVA Runtime Environment

JRE - JAVA 运行时环境

JVM - JAVA Virtual Machine

JVM - JAVA 虚拟机

JRE is the container, JVM is the content.

JRE 是容器,JVM 是内容。

回答by Justin Ethier

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 是“JRE”(Java 运行时环境)的实例,在执行 Java 程序时开始运行。当执行完成时,这个实例被垃圾回收。JIT 是 JVM 的一部分,用于加快执行时间。JIT 同时编译具有相似功能的部分字节码,从而减少编译所需的时间。

回答by Andrew Hubbs

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.

JRE 包括 JVM,它实际解释字节码并运行您的程序。为此,JVM 使用 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.

我相信你会说 JRE 就像 .NET Framework,而 JVM 就像 .NET CLR。不过,这里可能存在一些我不知道的重要差异。

回答by Daniel

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.

JVM 是运行 Java 代码的进程,而 JRE 是分布的所有文件,以形成 JVM 运行的“环境”。

回答by vipul_vj

Java Runtime Environment contains JVM, class libraries, and other supporting files.

Java 运行时环境包含 JVM、类库和其他支持文件。

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

实际上 JVM 运行程序,它使用类库和其他

supporting files provided in JRE.

JRE 中提供的支持文件。

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

JRE = JVM + Java 包类(如 util、math、lang、awt、swing 等)+ 运行时库。

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

如果要运行任何 Java 程序,则需要在系统中安装 JRE。

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

JRE 是盒子,JVM 是盒子的内容。

In simple words JRE = JVM + rt.jar

简单来说 JRE = JVM + rt.jar

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

其中 rt.jar 包含用于运行我们的程序的 lang、util、awt、swing、math 等库或已编译的 .class 文件。

Learn more about difference between JVM and JRE- CLICK HERE

详细了解 JVM 和 JRE 之间的区别-单击此处

回答by Balwant Kumar Singh

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

这个问题的简单答案是JREJVM的超集。

That is, the code which is compiled with java compiler(javac) produces the byte-code(.class files). jre which is the subset of jdkcontains 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.

也就是说,用 java 编译器(javac)编译的代码产生字节码(.class 文件)。jre 是jdk的子集,包含所需的库以及jvm。jvm 运行字节码并生成机器可读形式的机器代码,并支持该代码所需的库。

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.

要查看 jvm 的配置,请转到:C:\Program Files\Java\jre7\lib\i386\jvm.cfg
该文件包含可用作 java、javac 等选项的 JVM 列表。

回答by Mahesh Athreya

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).

首先JDK包含JRE+开发工具,JRE包含JVM+类库,其中JVM包含(类加载器&字节码验证器)和执行引擎(解释器&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.

编译器会将源代码转换为中间字节码。在此字节码被提供给JVM 执行时,JVM 中的类加载器将加载字节码并与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.

然后将代码交给 JVM 中的执行引擎,该引擎解释未重复的代码并编译重复的代码(例如循环),最终转换为机器代码(目标代码)。然后它将机器码交给微处理器执行。

回答by Nu-ONE

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.

JVM - java 虚拟机是一种用于执行字节码的运行时环境的规范。JRE-java运行环境是jvmJDK-java开发工具包的实现,是JRE+开发工具。

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.

JRE 拥有所有可以支持java 应用程序的类库。当 Java 应用程序即将执行时,JRE 将创建 JVM 实例,该实例将实际运行 Java 应用程序。

回答by Kulasangar

JREis an environment, in order to execute any Java program locally.

JRE是一个环境,以便在本地执行任何 Java 程序。

JVMis where it's responsible for converting the Bytecode into machine specific code and makes java program write-once-run-anywhere.

JVM负责将字节码转换为特定于机器的代码,并使 Java 程序一次编写,随处运行。

回答by Crroods

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).

JDK = JRE + 开发/调试工具,其中 JDK 是我们与 Java 一起使用的完整包,从创建编译到运行它。另一方面,JRE 只是运行代码(字节码)。

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.

注意:- 无论我们是安装 JDK 还是 JRE,JVM 都会与软件包捆绑在一起,而 JVM 是 JIT 编译器将字节码转换为机器特定代码的部分。

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.