Friday, October 16, 2020

Switch between Java versions on Fedora OS

Switching between multiple versions of Java on a Fedora OS (all *nix based OS)

To install multiple versions of Java refer this Blog

  • Check the current version of Java using the command
 java -version


Current version of java being used is 11.0.8
  • To switch to different installed version, issue the command
 sudo alternatives --config java

enter password if prompted for sudo

All the versions of Java installed currently will be shown as in image below 

Type in the number under "Selection" Column to switch to that version, for example type 1 to switch to java-1.8.0

  • Verify the version of java is changed as selected above

 java -version
 

After switching to a particular Java version (e.g. 11), see how it's linked to 'java' executable



Note: If you have JAVA_HOME variable set in ~/.bash_profile that needs to be removed. Restart is required upon removal 

No comments:

Post a Comment