Ubuntu 10.x with Java7

How to install Java on Ubuntu 10.x

Download he 32bit or 64bit Linux “compressed binary file” – it has a “.tar.gz” file extension i.e. “[java-version]-i586.tar.gz” for 32bit and “[java-version]-x64.tar.gz” for 64bit

Uncompress it
# tar -xvf jdk-7u2-linux-i586.tar.gz (32bit)
# tar -xvf jdk-7u2-linux-x64.tar.gz (64bit)

JDK 7 package is extracted into ./jdk1.7.0_02 directory. N.B. check carefully this folder name since Oracle seem to change this occasionally with each update.

Now move the JDK 7 directory to /usr/lib

# sudo mkdir -p /usr/lib/jvm
# sudo mv ./jdk1.7.0_02 /usr/lib/jvm/jdk1.7.0

Now run

# sudo update-alternatives –install “/usr/bin/java” “java” “/usr/lib/jvm/jdk1.7.0/bin/java” 1
# sudo update-alternatives –install “/usr/bin/javac” “javac” “/usr/lib/jvm/jdk1.7.0/bin/javac” 1
# sudo update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/lib/jvm/jdk1.7.0/bin/javaws” 1

This will assign Oracle JDK a priority of 1, which means that installing other JDKs will replace it as the default. Be sure to use a higher priority if you want Oracle JDK to remain the default. Correct the file ownership and the permissions of the executables:

# sudo chmod a+x /usr/bin/java
# sudo chmod a+x /usr/bin/javac
# sudo chmod a+x /usr/bin/javaws
# sudo chown -R root:root /usr/lib/jvm/jdk1.7.0

Check the version of you new JDK 7 installation:

# java -version

java version “1.7.0”
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)

Leave a Reply

Your email address will not be published. Required fields are marked *