With the utility update-alternatives, is possible you set versions of the Java installed in your Operating System Linux(which supports it), without need add or remove symbolic link manually. To list one or more Java version available in target system, you can just typing the command update-alternatives, adding the argument --list, together with name of the symlink(Symbolic Link) desired. For example:
update-alternatives --list java
Where java is the name of the symbolic link.
Also it is possible, you to install a new version, if by chance it hasn’t on the list of the update-alternatives. You can thus use the parameter --install, setting the following arguments:
- The value properly of the desired symbolic link name.
- The full path of the binary Java.
- Lastly, specifying the level of priority associated with it.
For example:
update-alternatives --install /usr/bin/java java /opt/jdk1.8/bin/java 1
After typing the command above, you can use the parameter --list to confirming the update:
update-alternatives --list java
To change to a new version, execute update-alternatives with parameter --config, it will show a menu to you choice your option through interactive way form:
update-alternatives --config java
There is another non-interactive way to you choice the version, just setting with parameter --set or -s, instead of --config, as below:
sudo update-alternatives --set java /opt/jdk1.8/bin/java
For more info, enter with:
man update-alternatives