I updated my 12.04 server with latest packages among them was an update to java 1.8u20.

Now I found out that my application is not running correctly with java 1.8u20. Now I looking for a way to downgrade Java to previous version or 1.8u5 in my case.

I tried to install a specific version

apt-get install oracle-java8-installer=8u5-1~webupd8~3
apt-get install oracle-java8-installer=8u5-1~webupd8
apt-get install oracle-java8-installer=8u5-1

E: Version 'XXX' for 'oracle-java8-installer' was not found

But the version I had from http://www.ubuntuupdates.org/ppa/webupd8_java?dist=saucy doesn't seem to work.

My Question is, how can I install a specific Version of java 8?


If you need install specific version of Java on any distro, you must do it manually, but it is easy.

First you need which architecture OS you have.

uname -a

The x86_64 is 64bit and ix86 (x can be 3 or 6).

If you have 64 bit OS (in present it is probably) follow this steps. -> Open the terminal.

1) Create directory and go to /opt/jdk

mkdir /opt/jdk
cd /opt

2) Download Java package (if someone need another version only need change version and build in link)

wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.tar.gz

3) Optional (if you are not logged as root you need):

sudo su

4) Untar the package:

tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk

5) Set Oracle's Java as default:

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100

6) Check Java version if it os ok

java -version

I follow this part of this tutorial, but this method is for anyone distro. For example I mainly used this for installation on servers where we nedd specific version of Java 7.

  • This was great, any chance of an edit for the UNDO of the update-alternatives ? – sjakubowski May 7 '15 at 20:50
  • Unfortunately because of oracle's certifcate scheme if you do wget --https-only it fails since the file resolves to download.ubuntu.com and the cert is from akamai for akamai domains. I'd really perfer to use apt to install software in general. Is there really no way to get specific java 8 versions through apt? – Groostav Jun 26 '15 at 19:25
  • Note you might still need to run update-alternatives --config java to point to the newer version. – ClojureMostly Feb 13 '18 at 14:52

I followed the steps for the answer and it is almost perfect.

update-alternatives does not make sure you have any necessary dependencies- it is just an official way to track softlinks from system folders to main exectubles for things like java and javac.

On my light version of Ubuntu 18.04 I was missing some x libraries. I was able to add those to get the desired result:

sudo apt-get install -y libxext-dev libxrender-dev libxtst-dev

I was running a java application that uses AWT / Screen objects. I was getting a crash with a NullPointerException in Main. Not very informative, but I had seen the same problem when my $DISPLAY was not set correctly to an X system ready to accept the java draw commands. Adding the x libraries will give you a fuller range of capabilities for the java you install.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.