JDK 和 JRE 是Java编程中的核心概念,它们的区别是一些最流行的面试问题。我们在编程时不使用这些概念,但是如果我们想成为Java开发人员,我们必须了解这些概念。
JDK
JDK 代表Java开发工具包。它是用于开发Java应用程序和小程序的软件开发环境。它是一个特定于平台的软件,即对于 Windows、Mac 和 Unix 系统有单独的安装程序。 Java开发人员可以在他们的 Windows、macOS、Solaris 和 Linux 上使用它来编写和运行Java程序。它包含Java运行时环境 (JRE) 和其他开发工具,如解释器、编译器、存档器和文档生成器。我们可能会在同一台计算机上安装多个 JDK 版本。
JRE
JRE 代表Java运行时环境。 它是JVM(Java虚拟机)的实现 它是专门为提供执行Java程序的环境而设计的。它也像JDK一样依赖于平台。它由JVM、 Java二进制文件和其他用于程序顺利执行的类组成。它不包含任何开发工具,如编译器、调试器等。如果我们只想执行一个程序,我们只需要安装 JRE 而不是 JDK,因为不需要开发或编译代码。
让我们借助下图看看主要区别:
JDK 和 JRE 的区别
KEY | JDK | JRE |
---|---|---|
DEFINITION | JDK(Java Development Kit) is used to develop Java applications. JDK also contains numerous development tools like compilers, debuggers, etc. | JRE(Java Runtime Environment) is the implementation of JVM(Java Virtual Machine) and it is specially designed to execute Java programs. |
FUNCTIONALITY | It is mainly used for the execution of code and its main functionality is development. | It is mainly used for creating an environment for code execution. |
DEPENDENCY OF PLATFORM | It is platform-dependent. | It is also platform-dependent like JDK. |
TYPE OF TOOLS | Since JDK is responsible for the development purpose, therefore it contains tools which are required for development and debugging purpose. | On the other hand, JRE is not responsible for development purposes so it doesn’t contain such tools as the compiler, debugger, etc. Instead, it contains class libraries and supporting files required for the purpose of execution of the program. |
IMPLEMENTATION OF JDK AND JRE | JDK = JRE + other development tools. | JRE = JVM + other class libraries. |