Skip to content

Instantly share code, notes, and snippets.

@vanjis
Last active February 1, 2021 15:31
Show Gist options
  • Save vanjis/d3d93344c10adc684852fce448ca9c1c to your computer and use it in GitHub Desktop.
Save vanjis/d3d93344c10adc684852fce448ca9c1c to your computer and use it in GitHub Desktop.
Switch java version on windows
Create a new "java8.bat" file.
Add the following in the file and save.
```
@echo off
set JAVA_HOME=C:\OpenJDK_1_8_RedHat\java-1.8.0-openjdk-1.8.0.232-3.b09.redhat
set Path=%JAVA_HOME%\bin;%Path%
echo Java 8 activated.
```
Create a new "java11.bat" file.
Add the following in the file and save.
```
@echo off
set JAVA_HOME=C:\AdoptOpenJDK\AdoptOpenJDK_11.0.7_10
set Path=%JAVA_HOME%\bin;%Path%
echo Java 11 activated.
```
Move both the files to the same folder and add the folder path to the environment variable - "PATH"
Open command prompt and run java8 to activate Java8.
Run java11 to activate Java11.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment