banner



How To Change Java Version In Windows 10

In this commodity, I will evidence you how to install multiple Java versions on Windows and how to alter the Java version on the control line:

Multiple Java versions on Windows

To enable these Java version change commands on your system as well, follow this step-by-step guide.

Allow's become…

Step 1: Installing Multiple Coffee Versions

Installing multiple Java versions in parallel is incredibly easy in Windows. You can download and run the installer for each version, which automatically installs the versions in divide directories.

Download Sources

  • Coffee SE 1.1 – You can no longer install this version on 64-scrap Windows.
  • Java SE 1.ii – Installed to C:\jdk1.2.2\ and C:\Program Files (x86)\JavaSoft\JRE\1.ii\ by default – I recommend changing this to C:\Program Files (x86)\Java\jdk1.2.ii\ and C:\Program Files (x86)\Java\jre1.2.2\ for the sake of clarity.
  • Java SE ane.3 – Installed to C:\jdk1.3.1_28\ by default – I recommend changing this to C:\Program Files (x86)\Java\jdk1.3.1_28\.
  • Java SE 1.iv – Installed to C:\j2sdk1.4.2_19\ past default – I recommend changing this to C:\Plan Files (x86)\Java\jdk1.4.2_19\.

Starting with the post-obit versions, you don't demand to alter the default installation directories:

  • Java SE 5
  • Java SE 6
  • Java SE 7
  • Java SE viii
  • Coffee SE 9 / OpenJDK ix
  • Java SE 10 / OpenJDK ten (→ The most important new features in Coffee 10)

Attention – you may utilize the following Oracle distributions only for private purposes and development:

  • Java SE 11 / OpenJDK 11 (→ The most important new features in Java eleven)
  • Java SE 12 / OpenJDK 12 (→ The nigh important new features in Coffee 12)
  • Java SE 13 / OpenJDK thirteen (→ The nearly of import new features in Java 13)
  • Java SE 14 / OpenJDK 14 (→ The most important new features in Java xiv)
  • Coffee SE 15 / OpenJDK 15 (→ The most important new features in Java 15)
  • Java SE 16 / OpenJDK xvi (→ The nearly important new features in Java 16)
  • Java SE 17 / OpenJDK 17 (→ The about important new features in Java 17)
  • Java SE 18 / OpenJDK eighteen (→ The most important new features in Coffee xviii)

The following version is currently an early access build. You should use it only for testing purposes:

  • JDK 19 Early on-Admission Build

Step 2: Define Java Environment Variables

The following ii environment variables decide which Coffee version an application uses:

  • JAVA_HOME – many kickoff scripts use this variable.
  • Path – is used when running a Java binary (such as java and javac) from the console.

These variables should e'er point to the same Java installation to avoid inconsistencies. Some programs, such equally Eclipse, define the Java version in a dissever configuration file (for Eclipse, for example, this is the entry "-vm" in the eclipse.ini file).

Manually Setting the Coffee Surroundings Variables

The Java installers create various environment variables, which you lot need to clean up first (encounter below). The fastest way to change the environment variables is to press the Windows key and type "env" – Windows then offers "Edit the organization environs variables" as a search consequence:

Opening Windows environment variables
Opening Windows environment variables

At this point, you can printing "Enter" to open the system properties:

Windows 10 System Properties
Windows x Organisation Properties

Click on "Surround Variables…" and the following window opens:

Windows environment variables Java 18
Windows surround variables Java 18

Equally the default version, I recommend the electric current release version, Java eighteen. Accordingly, y'all should brand the following settings:

  • The top list ("User variables") should non contain any Java-related entries.
  • The lower list ("Organisation variables") should contain an entry "JAVA_HOME = C:\Program Files\Java\jdk-18". If this entry does not exist, y'all tin can add information technology with "New…". If information technology exists but points to some other directory, yous can change it with "Edit…".
  • Delete the following entries under "Path":
    • C:\ProgramData\Oracle\Java\javapath
    • C:\Program Files (x86)\Common Files\Oracle\Java\javapath
  • Insert the following entry instead:
    • %JAVA_HOME%\bin

The entry should then look like the following (the other entries in the list will probably await different for you since you accept other applications installed than I do):

Adding "%JAVA_HOME%\bin" to the "Path" system variable
Adding "%JAVA_HOME%\bin" to the "Path" arrangement variable

The last entry ensures that Path and JAVA_HOME are automatically consistent.

Attention: this only works for the default setting configured here. If y'all change JAVA_HOME via the command line, you have to arrange Path accordingly. Simply don't worry – the scripts yous can download in the side by side step volition do that automatically.

How to Check Your Java Version on Windows

At present open a command line to cheque the settings with the following commands:

              

echo %JAVA_HOME% java -version

Code language: plaintext ( plaintext )

Hither'southward what you should run across:

Check your Java version with "cmd"
Check your Java version with "cmd"

Step three: Install the Scripts to Modify the Java Version

To change the Coffee version on the command line, I have prepared some batch files that y'all can copy to your arrangement. Here is the link: scripts-up-to-java19.zip

The ZIP file contains scripts named java19.bat, java18.bat, java17.bat, etc., for all Coffee versions. I suggest you unpack the scripts to C:\Program Files\Coffee\scripts.

The scripts look like this (java18.bat):

              

@repeat off fix JAVA_HOME=C:\Program Files\Java\jdk-xviii gear up Path=%JAVA_HOME%\bin;%Path% echo Java 18 activated.

Code language: DOS .bat ( dos )

The script updates the JAVA_HOME surroundings variable and inserts the bin directory at the beginning of the Path variable. That makes it the first directory to be searched for the corresponding executable when you run Java commands such equally java or javac.

(The Path variable gets longer with each change. Do not worry about it. This but affects the currently opened command line.)

Step 4: Add the Script Directory to the Path

To be able to call the scripts from anywhere, you have to add together the directory to the "Path" environment variable (just like y'all did with "%JAVA_HOME%\bin" in the 2d step):

Adding "C:\Program Files\Java\scripts" to the "Path" system variable
Adding "C:\Program Files\Coffee\scripts" to the "Path" arrangement variable

If you have installed the latest releases of all Coffee versions, you can use the scripts without whatsoever further adjustments. Open up a new command line and enter, e.chiliad., the following commands:

Changing the Java version
Changing the Java version

If one of the commands does not activate the expected Coffee version, delight check if the path in the batch file corresponds to the installation path of the Coffee version you want to actuate.

Temporary, Permanent, and System-Wide Coffee Version Changes

The commands presented up to this betoken merely impact the currently opened command line. Every bit soon every bit you open up another command line, the default version defined in step ii is active again (Java eighteen, if you have not changed anything).

That is why there are not i but three scripts for each Java version:

  • java<version>: Activates the Java version in the current command line.
  • java<version>-user: Sets the Coffee version as the default version for your user account.
  • java<version>-system: Sets the Java version as the default version for the entire system-

The -user variants of the scripts additionally set up the JAVA_HOME environment variable with the setx control, permanently writing the change to the registry:

              

@echo off set JAVA_HOME=C:\Program Files\Java\jdk-18 setx JAVA_HOME "%JAVA_HOME%" set Path=%JAVA_HOME%\bin;%Path% echo Java 18 activated as user default.

Code language: DOS .bat ( dos )

The -system variants also specify the /Chiliad parameter in the setx command. This sets the system-broad environment variable instead of the user-specific one:

              

@repeat off ready JAVA_HOME=C:\Program Files\Java\jdk-18 setx JAVA_HOME "%JAVA_HOME%" /M ready Path=%JAVA_HOME%\bin;%Path% echo Java 18 activated as system-wide default.

Code language: DOS .bat ( dos )

Attending: To set the system-wide Coffee version, you must open the command line equally an administrator. Otherwise, you will get the mistake message "Error: Access to the registry path is denied.

What You Should Do Next…

I hope you lot were able to follow the instructions well and that the commands piece of work for you.

At present I would like to hear from yous:

Were you able to follow the steps well – or do you take unanswered questions?

Either way, let me know by leaving a comment below.

Source: https://www.happycoders.eu/java/how-to-switch-multiple-java-versions-windows/

Posted by: walkerbeeks1962.blogspot.com

0 Response to "How To Change Java Version In Windows 10"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel