Oracle Java and update-alternatives

Environment: Ubuntu 14.04

The Linux alternatives system is an excellent way to install and use different program equivalents. If you update Oracle Java quite often (or even once), it can be a tedious task installing new links and removing any old ones.

Since I always install the JDKs in the /usr/lib/jvm directory with the pattern jdk* (eg /usr/lib/jvm/jdk1.8.0_20), this can make it easy for a script to find all of the JDKs. The script shown below will search for all of the JDKs in /usr/lib/jvm and allow you to install or remove all of the programs in the JDK’s bin directory into the alternatives system.

The syntax is:

to install a JDK and

to remove a JDK.

The script will show the list of JDKs and prompt as to which JDK it should perform the install or delete. Selecting the number corresponding to the JDK and hitting Enter will start the operation.

No Comment.

Add Your Comment