简体   繁体   English

JDK包含src.zip但JRE没有

[英]JDK contains src.zip but JRE doesn't

Just noticed that JDK contains src.zip with a set of java files. 刚刚注意到JDK包含带有一组java文件的src.zip I checked JRE and didn't found it over there. 我检查了JRE并没有在那里找到它。

Does it mean the JVM does not need these files in order to run my code? 这是否意味着JVM不需要这些文件才能运行我的代码?

That's right, the JRE does not need Java source files to run your code. 没错,JRE不需要Java源文件来运行你的代码。

The src.zip file includes the Java sources for the JDK library types and (apparently) some Sun JVM implementations of those types as well. src.zip文件包含JDK库类型的Java源代码,以及(显然)这些类型的一些Sun JVM实现。

The JRE doesn't need your source files either, but the JDK includes a tool (javac) that compiles your sources to Java bytecode for execution on the JRE. JRE也不需要您的源文件,但JDK包含一个工具(javac),它将源代码编译为Java字节码以便在JRE上执行。

These files are here to provide the source of the JDK classes, this way, it's easier for developers how some classes act (but the javadoc should be sufficient). 这些文件在这里提供了JDK类的源代码,这样,开发人员更容易处理一些类的行为(但是javadoc应该足够了)。

So no, no need for clients to read the JDK source code. 所以不,客户端无需读取JDK源代码。 The only thing needed to run Java applications is the .jar containing all the .class for JDK Classes. 运行Java应用程序唯一需要的是包含JDK Classes所有.class的.jar。

The JDK (Java Development kit) is, as the name implies, a Development Kit, so it includes tools and resources that are useful for developers. 顾名思义,JDK(Java开发工具包)是一个开发工具包,因此它包含对开发人员有用的工具和资源。 Many of these tools or resources are not actually required in order to run Java applications. 为了运行Java应用程序,实际上并不需要许多这些工具或资源。 Specifically, src.zip contains source code that is useful for developers, but indeed is not required to run Java applications. 具体来说, src.zip包含对开发人员有用的源代码,但实际上并不需要运行Java应用程序。

The JRE (Java Runtime Environment), in contrast, includes only the JVM and tools and resources that are necessary in order to run Java applications. 相反,JRE(Java运行时环境)仅包括JVM以及运行Java应用程序所必需的工具和资源。

So, in short, in order to run Java applications you only require the JRE. 因此,简而言之,为了运行Java应用程序,您只需要JRE。 Anything in the JDK that is not present in the JRE is not required. JDK中不存在于JRE中的任何内容都不是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM