简体   繁体   中英

Java update only jre and not jdk

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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