install specific java version for 12.04

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 doesn't seem to work.

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

2 Answers

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" 

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.

3

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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like