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.
(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.
(2) Click "System and Security" from the "Control Panel" screen.
③ Click "System" from the "System and Security" screen.
④ Click "Detailed system settings" in the left menu from the "System" screen.
⑤ The "System Properties" screen opens. Click "Environment Variables".
(6) The "Environment Variables" screen is displayed. 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.
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.
(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.
(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".
(3) Check the created JAVA_HOME setting.
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".
(2) The "Edit system environment variables" screen opens. Enter the directory of the JDK you want to use in "Variable value".
(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. If the Java version is switched as described above, it is successful.
Reference site: https://www.javadrive.jp/start/install/index4.html
Recommended Posts