JDK/JRE/JVM/Java SDK | 它们都是什么意思?有时您可以使用 JRE 进行开发,有时您需要 JDK?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2277275/
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
JDK/JRE/JVM/Java SDK | What do they all mean? Sometimes you can develop with JRE and sometimes you need JDK?
提问by Javed Ahamed
To tell the truth, I am quite confused on all these terms (JDK/JRE/Java SDK). I am not sure what each one does.
说实话,我对所有这些术语(JDK/JRE/Java SDK)都很困惑。我不确定每个人是做什么的。
When I first started doing simple java examples in eclipse, I am pretty sure I only had the JRE, which I believed was the default java installer regular users use to be able to run java programs/applets on their system.
当我第一次开始在 eclipse 中做简单的 java 示例时,我很确定我只有 JRE,我相信这是默认的 java 安装程序,普通用户用来能够在他们的系统上运行 java 程序/小程序。
However, now in class we are using Google Appengine, and this requires the JDK which I am guessing is the same as Java SDK. After wasting some time finding out that installing the JDK meant I also had to add java/bin to the environment variables to get javac -version to work in the command prompt I find that only the JDK has javac...
但是,现在在课堂上我们正在使用 Google Appengine,这需要 JDK,我猜它与 Java SDK 相同。浪费了一些时间发现安装 JDK 意味着我还必须将 java/bin 添加到环境变量中才能让 javac -version 在命令提示符下工作,我发现只有 JDK 有 javac...
How were my early java programs working without having installed the JDK and therefore not having javac? And really the main question... What is the difference between the JRE and JDK, and when do you use each one?
我的早期 Java 程序在没有安装 JDK 因而没有 javac 的情况下如何工作?真正的主要问题是... JRE 和 JDK 之间有什么区别,您什么时候使用它们?
Thank you :)
谢谢 :)
采纳答案by Chris Jester-Young
Eclipse has its own built-in compiler (called ecj
), which is probably the reason you could get away with not having the JDK installed to use it. It does not use javac
.
Eclipse 有其自己的内置编译器(称为ecj
),这可能是您无需安装 JDK 即可使用它的原因。它不使用javac
.
Google App Engine uses the javac
that comes with the JDK.
Google App Engine 使用javac
JDK 附带的 。
回答by Vivin Paliath
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
JRE = Java 运行时环境 - 运行需要 Java 或使用 Java 编写的库的程序/软件所需的条件。例如,OpenOffice 需要 Java 运行时环境
JDK/Java SDK = Java Development Kit/Java Software Development Kit - what you need to writeprograms that require Java or use libraries written in Java. For example, if you were to write your own word-processing tool in Java.
JDK/Java SDK = Java 开发工具包/Java 软件开发工具包 -编写需要 Java 的程序或使用 Java 编写的库需要什么。例如,如果您要使用 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.
java
附带 JRE,因为它启动 VM(虚拟机)。它可以接收class
使用 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.
JDK 附带了它,javac
因为这是将.java
文件编译成.class
可以在 JRE 上运行的文件所需要的。
回答by Cesar
There's no way you used the JRE to compile Java programs. javac, the Java compiler, only comes with the JDK.
您无法使用 JRE 来编译 Java 程序。javac,Java 编译器,只随 JDK 一起提供。
- You may write Java programs with whatever text editor, you don't need anything special to do this.
- You need the JRE to run Java programs. The JRE includes the Java Virtual Machine, needed to run already compiled Java programs.
- You need the JDK to compile Java programs. So if you are a Java developer, you may want to only install the JDK since it comes with the tools needed to compile, in addition to the Java Virtual Machine.
- 你可以用任何文本编辑器编写 Java 程序,你不需要任何特殊的东西来做到这一点。
- 您需要 JRE 才能运行 Java 程序。JRE 包括 Java 虚拟机,需要运行已编译的 Java 程序。
- 您需要 JDK 来编译 Java 程序。因此,如果您是 Java 开发人员,除了 Java 虚拟机之外,您可能只想安装 JDK,因为它附带了编译所需的工具。
回答by OscarRyz
What is the difference between the JRE and JDK and when do you use each one?
JRE 和 JDK 有什么区别,你什么时候使用它们?
JRE: Java Runtime Environment. It is used to run Java programs only. As Chris Jester -Youngmentioned, Eclipse had a built in compiler. That's why you just needed JRE ( to run eclipse )
JRE:Java 运行时环境。它仅用于运行 Java 程序。正如Chris Jester -Young提到的,Eclipse 有一个内置的编译器。这就是为什么你只需要 JRE(运行 eclipse )
If you ship a Java program, the only thing the client need to have is this runtime environment
如果你发布一个 Java 程序,客户端唯一需要的就是这个运行时环境
JDK: Java Develpment Kit, this also includes a JRE inside, but additionally have other tools for program development such as the java compiler javacamong many others.
JDK: Java Develpment Kit,这里面也包含了一个JRE,但是另外还有其他的程序开发工具,比如java编译器javac等等。
If you want to create java program you should use this.
如果你想创建java程序,你应该使用它。
回答by user207421
'Sometimes you can develop with jre'
'有时你可以用 jre 开发'
No. Never.
没有永不。
You develop with the Java Development Kit. You run with the Java Runtime Environment or Engine or whatever it's called.
您使用 Java 开发工具包进行开发。您可以使用 Java 运行时环境或引擎或任何名称来运行。