Java只更新JRE而不更新JDK。

huangapple go评论70阅读模式
英文:

Java update only jre and not jdk

问题

我无法理解Java的更新情况。
在使用Windows 10时,当我打开 C:\Program Files\Java 路径,我看到了三个文件夹:

-jdk1.8.0_221

-jre1.8.0_251

-jre1.8.0_261

当我在命令提示符(cmd)中输入 java -version 时,得到以下结果:

java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

当我输入 javac -version 时,得到以下结果:

javac 1.8.0_221

我已经检查了环境变量,没有任何与Java相关的内容。
当我在命令提示符中输入 where java 时,得到以下结果:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files\Java\jdk1.8.0_221\bin\java.exe

而当我输入 where javac 时,得到以下结果:

C:\Program Files\Java\jdk1.8.0_221\bin\javac.exe

问题如下:

  1. 如果1.8.0_261是最新的Java版本,为什么更新后只更新了jre而没有更新jdk?为什么jdk仍停留在221版本?
  2. 即使jdk最新版本是221,jre最新版本是261,为什么它还保留了jre 251的文件夹?为什么没有删除它?我应该删除吗?
  3. 为什么我的javac也没有更新?为什么 "where" 命令直接指向了221文件夹?更新后会改变吗?

谢谢。

英文:

I can't understand java updates.
Using Windows 10, When I go to C:\Program Files\Java I have 3 folders:

-jdk1.8.0_221

-jre1.8.0_251

-jre1.8.0_261

When I open cmd and type java -version I get:

java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

When I type javac -version I get:

javac 1.8.0_221

I checked environment variables, It has noting associating with Java.
When I type in cmd where java I get:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files\Java\jdk1.8.0_221\bin\java.exe

And when I type where javac I get:

C:\Program Files\Java\jdk1.8.0_221\bin\javac.exe

The questions:

  1. If 1.8.0_261 is lateast java version, why when I update it only updates jre and not jdk? why jdk is staying at 221?
  2. Even if jdk lateast version is 221 and jre lateast version is 261, why it keep saving the jre 251 folder? why it doesnt delete it? should I delete it?
  3. Why my javac is not updating as well? Why the "where" command pointing stright to the 221 folder name.. Does it change when I update?

Thanks.

答案1

得分: 2

JDK是Java的开发工具包,JRE是运行时环境。JDK本身包含JRE。要运行Java应用程序,您需要JRE。然而,某些程序在运行时需要编译器,所以在这种情况下,您需要JDK。

由于JDK包含JRE。因此,最好使用JDK。

以下是在您的系统中设置Java的步骤。

  1. 从Java Oracle在您的系统中安装任何JDK。

  2. 系统变量中设置JAVA_HOME变量为

    C:\Program Files\Java\jdk1.8.0_261\

设置完后,系统将知道您已安装了JDK。现在您的系统不知道javac用于编译Java应用程序。

  1. 在相同的系统变量中设置Path_Variable

    %JAVA_HOME%\bin

通过这样做,您的系统将识别javac编译器。

英文:

JDK is the development kit for Java and JRE is the runtime environment. The JDK itself contains the JRE. To run a Java application you need JRE. However, some program needs compiler at runtime so in that case, you need JDK.

As JDK contains the JRE. So, it is preferable to use JDK.

Following is the step to setup Java in your system.

  1. Install any JDK in your system from Java Oracle.

  2. Set JAVA_HOME variable in the System variables as

    C:\Program Files\Java\jdk1.8.0_261\ .

After setting it, the system will know you have JDK installed. Now your system doesn't know about javac to compile the java application.

  1. Set Path_Variable in the same System variables

    %JAVA_HOME%\bin.

From this, your system will recognize the javac compiler.

答案2

得分: 1

If 1.8.0_261 is lateast java version, why when I update it only
updates jre and not jdk? why jdk is staying at 221?

我相信您已经知道JDKJava开发工具包,而JREJava运行环境,它们是不同的东西。您可以从https://www.oracle.com/uk/java/technologies/javase/javase-jdk8-downloads.html 安装最新版本的JDK 1.8,而要安装最新版本的JRE 1.8,您需要从https://www.oracle.com/java/technologies/javase-jre8-downloads.html 下载二进制文件。当您安装JDK 1.8时,它还会询问您是否要安装JRE

Even if jdk lateast version is 221 and jre lateast version is 261, why
it keep saving the jre 251 folder? why it doesnt delete it? should I
delete it?

是的,可以安全地删除它。

Why my javac is not updating as well? Why the "where" command pointing
stright to the 221 folder name.. Does it change when I update?

javac命令是JDK的一部分,而不是JRE的一部分。因此,where javac将始终返回JDK安装的位置。

英文:

> If 1.8.0_261 is lateast java version, why when I update it only
> updates jre and not jdk? why jdk is staying at 221?

I believe you already know that JDK is the Java Development Kit whereas JRE is the Java Runtime Environment and they are different things. You can install the latest version of JDK 1.8 from https://www.oracle.com/uk/java/technologies/javase/javase-jdk8-downloads.html whereas to install the latest version of JRE 1.8, you need to download the binary from https://www.oracle.com/java/technologies/javase-jre8-downloads.html. When you install JDK 1.8, it also asks if you want to install the JRE as well.

> Even if jdk lateast version is 221 and jre lateast version is 261, why
> it keep saving the jre 251 folder? why it doesnt delete it? should I
> delete it?

Yes, it is safe to delete it.

> Why my javac is not updating as well? Why the "where" command pointing
> stright to the 221 folder name.. Does it change when I update?

The command, javac is part of JDK; not JRE. Therefore, where javac will always return you the location of JDK installation.

huangapple
  • 本文由 发表于 2020年9月5日 22:03:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/63754747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定