How to switch between multiple Java versions

How to switch between multiple versions of Java

It took a lot of time when I tried to switch between multiple versions of Java, so I will record it as a memorandum. It is described from the place where the environment variable is set first. This environment is Windows 10 64bit.

Open the environment variable setting screen

(1) Click the Windows Start menu, and then click "Windows System Tools" from the displayed application list. Then click "Control Panel" from the expanded menu to open it. windows10システムメニュー.jpg システムツールからコントロールパネル.jpg

(2) Click "System and Security" from the "Control Panel" screen. システムとセキュリティ.jpg

③ Click "System" from the "System and Security" screen. システム.png

④ Click "Detailed system settings" in the left menu from the "System" screen. システムの詳細設定.png

⑤ The "System Properties" screen opens. Click "Environment Variables". 環境変数.png

(6) The "Environment Variables" screen is displayed. WS000013.JPG NOTE: User environment variables are only valid for the currently logged in user. System environment variables are valid for all users. If you set an environment variable with the same name in both, the value set in the user environment variable is valid.

Setting the environment variable JAVA_HOME

Next, set the environment variable JAVA_HOME. The environment variable JAVA_HOME is a container that holds the storage location of the JDK. When using Java in other applications, etc., the storage location of the JDK is calculated from the value of JAVA_HOME.

Add environment variable JAVA_HOME

(1) If JAVA_HOME does not exist in the system environment variable, create a new one. Click the "New" button under the system environment variables on the "Environment Variables" screen. JAVA_HOME新規作成.png

(2) The "New System Variable" screen opens. Enter "JAVA_HOME" in "Variable name" and the directory of the JDK you installed yourself in "Variable value". WS000014.JPG

(3) Check the created JAVA_HOME setting.

Use a different JDK

If you want to use another JDK, change the value of JAVA_HOME in the previous section to the directory of the JDK you want to use.

(1) Select "JAVA_HOME" on the "Environment Variables" screen and click the edit button under "System Variables". システム環境変数の編集.png

(2) The "Edit system environment variables" screen opens. Enter the directory of the JDK you want to use in "Variable value". WS000016.JPG

(3) Close the environment variable setting screen as when creating a new one, and then enter set JAVA_HOME at the new command prompt. Enter java -version and javac -version to see if the Java version has changed. WS000019.JPG If the Java version is switched as described above, it is successful.

Reference site: https://www.javadrive.jp/start/install/index4.html

Recommended Posts

How to switch between multiple Java versions
How to switch Java versions on Mac
Switch between multiple versions of Java on Mac
Use jenv to enable multiple versions of Java
[Java] How to switch from open jdk to oracle jdk
[Java] How to make multiple for loops single
[Java] How to use Map
How to lower java version
[Java] How to use Map
How to uninstall Java 8 (Mac)
How to use java Optional
How to minimize Java images
How to write java comments
How to use java class
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to display Wingdings
[Java] How to use string.format
How to use Java Map
How to set Java constants
How to use Java variables
[Java] How to implement multithreading
How to initialize Java array
Java conditional branching: How to create and study switch statements
Difference between Java and JavaScript (how to find the average)
How to dynamically switch JDK when building Java in Gradle
Differences in how to handle strings between Java and Perl
How to switch Java in the OpenJDK era on Mac
How to dynamically switch between FIN and RST in Netty
How to study Java Silver SE 8
How to use Java HttpClient (Get)
Operation to connect multiple Streams @Java
Studying Java # 6 (How to write blocks)
[Java] How to update Java on Windows
How to make a Java container
How to disassemble Java class files
How to use Java HttpClient (Post)
[Java] How to use join method
[Processing × Java] How to use variables
[Java] How to create a folder
How to decompile java class files
[Java] How to use LinkedHashMap class
[JavaFX] [Java8] How to use GridPane
How to write Java variable declaration
How to use class methods [Java]
[Java] How to use List [ArrayList]
How to name variables in Java
How to pass Oracle Java Silver
How to turn Iterator Dojo (Java)
[Processing × Java] How to use arrays
How to make a Java array
How to use Java lambda expressions
[Java] How to use Math class
How to find Java prime numbers
How to use Java enum type
How to concatenate strings in java
How to switch Java version with direnv in terminal on Mac
How to check Java installed on Mac
How to implement date calculation in Java
How to implement Kalman filter in Java
Multilingual Locale in Java How to use Locale