JDK 和 JRE 有什么区别? [英] What is the difference between JDK and JRE?

查看:27
本文介绍了JDK 和 JRE 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JDK 和 JRE 有什么区别?

What is the difference between JDK and JRE?

它们的作用是什么,我什么时候应该使用其中一个?

What are their roles and when should I use one or the other?

推荐答案

JREJava 运行时环境.它是运行编译后的 Java 程序所需的一切的包,包括 Java 虚拟机 (JVM)、Java 类库、java 命令和其他基础设施.但是,它不能用于创建新程序.

The JRE is the Java Runtime Environment. It is a package of everything necessary to run a compiled Java program, including the Java Virtual Machine (JVM), the Java Class Library, the java command, and other infrastructure. However, it cannot be used to create new programs.

JDKJava 开发工具包,是用于 Java 的全功能 SDK.它拥有 JRE 的一切,还有编译器(javac)和工具(如 javadocjdb).它能够创建和编译程序.

The JDK is the Java Development Kit, the full-featured SDK for Java. It has everything the JRE has, but also the compiler (javac) and tools (like javadoc and jdb). It is capable of creating and compiling programs.

通常,如果您只关心在计算机上运行 Java 程序,您只会安装 JRE.这就是你所需要的.另一方面,如果您打算进行一些 Java 编程,则需要安装 JDK.

Usually, if you only care about running Java programs on computer you will only install the JRE. It's all you need. On the other hand, if you are planning to do some Java programming, you need to install the JDK instead.

有时,即使您不打算在计算机上进行任何 Java 开发,您仍然需要安装 JDK.例如,如果您使用 JSP 部署 Web 应用程序,那么从技术上讲,您只是在应用程序服务器内运行 Java 程序.那你为什么需要JDK?因为应用服务器会将JSP 转换成Java servlet,需要使用JDK 来编译servlet.我相信还有更多的例子.

Sometimes, even if you are not planning to do any Java development on a computer, you still need the JDK installed. For example, if you are deploying a web application with JSP, you are technically just running Java programs inside the application server. Why would you need the JDK then? Because the application server will convert JSP into Java servlets and needs to use the JDK to compile the servlets. I am sure that there are more examples.

这篇关于JDK 和 JRE 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆