11/20/2023 0 Comments Java jdkubuntu![]() ![]() The next step is to add these scripts as aliases to. Similarly, you can create scripts for other Java versions installed on your machine. Java8.sh sudo update-java-alternatives -s java-1.8.0-openjdk-amd64Įxport JAVA_HOME =/usr/lib/jvm/java-1.8.0-openjdk-amd64/ Here is the script I used for switching to OpenJDK 8 on my machine. If you frequently switch between different Java versions, it is a good idea to write a short script to automate the process. The default Java version is changed to OpenJDK 11. OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.10.3, mixed mode, sharing ) OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.10.3 ) Now you can verify the default Java version as fellows: $ java -version If the list does not include your desired Java version, you can always install it. When prompted, select the Java version you would like to use. Press to keep the current choice, or type selection number: * 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode There are 2 choices for the alternative java (providing /usr/bin/java ).Ġ /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto modeġ /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode Running the above command displays a list of installed Java JDKs and JREs allowing you to select the one as you want to set as default. Now, let's run the following command to see all available Java versions: $ sudo update-alternatives -config java OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode )Īs you can see above, the default Java version is currently set to OpenJDK JRE 1.8. First of all, run the following command to check the current Java version: $ java -version In this tutorial, I'll explain how to change the default Java version on a Linux machine. But the good thing is you can install multiple Java versions on your machine and quickly change the default JRE version. Now, if you run this program on a Linux machine where an unsupported Java version is installed, you will encounter an exception.įor example, if your program is compiled on Java 11, it can't be run on a machine where Java 8 is installed. ![]() When a Java program is compiled, the build environment sets the oldest JRE version the program can support. If you are a Java developer, it is normal to have multiple Java versions installed on your machine to support different build environments.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |