2

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.

3
  • The java updater seems to only update the JRE. javac is the compiler and is only part of the jdk. Commented Sep 5, 2020 at 14:06
  • JRE and JDK are two different things. JRE is used for Run app, JDK for Development. Commented Sep 5, 2020 at 14:55
  • So the solution (on Windows) is to manually install the latest JDK if you want to update javac and the other development tools. (On Linux (RHEL, Ubuntu, etc), the package manager will update both sets of tools ... when you tell it to.) Commented Sep 5, 2020 at 14:57

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Check which java JDK version has installed in your system in the control panel.
Uninstall unnecessarily JRE/JDK. Manually delete the corresponding JDK/JRE folder. Manually install the JDK from the Java Oracle site and set the path accordingly.
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?

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.