Install
Java JDK 7 on Ubuntu 12.04
1.
To add our PPA and install the latest Oracle Java (JDK) 7 in Ubuntu,
use the commands below:
#sudo
add-apt-repository ppa:webupd8team/java
#sudo
apt-get update && sudo apt-get install oracle-jdk7-installer
2.
After the installation you have enable the jdk:
#update-alternatives
--display java
3.
Check if Ubuntu uses Java JDK 7
#java
-version
------------------------------
java
version "1.7.0_25"
Java(TM)
SE Runtime Environment (build 1.7.0_25-b15)
4.
Check what compiler is used:
#javac
-version
------------------------------
java
version "1.7.0_25"
Java(TM)
SE Runtime Environment (build 1.7.0_25-b15)
5.
Adding JAVA_HOME to environment
Edit
/etc/environment and
add JAVA_HOME=/usr/lib/jvm/java-7-oracle
to the end of the file.
Additional
Steps (optional):
*
In your machine, already installed any java versions then you can run
the below to update the alternatives
#update-alternatives
--config java
*
Currently If you are used any other java version and in the same
environment if you installed the Java7.
There
are situations even you set the JAVA_HOME
for Java 7,
it applied only for the root operations but not for the
other users.
In such occations you have to edit the .bashrc and
add the JAVA_HOME.
#sudo
gedit /home/sanjeeva/.bashrc
*
Removing Oracle JDK 7
If
you don’t want to use Oracle Java (JDK) 7 anymore and want to go
back to OpenJDK, all you have to do is remove the Oracle JDK7
Installer and the previous Java (OpenJDK, etc.) version will be used;
#sudo
apt-get remove oracle-jdk7-installer