Friday, February 24, 2012

Oracle JDK 7 install on Ubuntu 11

For some reason, I guess because of license reason. Oracle doesn't have Ubuntu software repository.
so you need to install it manually, you can't use apt-get inatall command.
Let's see how to install Oracle(Sun) JDK 7 install on Ubuntu

Download jdk7 for linux, don't download rpm package.
rpm package is for Rad hat linux. just download tz , tar file extension

1.Extract files.

2.fire up the terminal and type:

Move the extracted jdk folder to the default installation folder for java.
and make a link.
sudo mv jdk1.7.0 /usr/lib/jvm
ln jdk1.7.0_02 java-7-sun
sudo update-alternatives --config java

Next, type this command and count the number of java version you have.
sudo update-alternatives --config java

Once you have that number enter this command and change the number on the end of it to the number you just found plus one.

this command mean is, you add one more java command on system.
later on, you can switch to another java easily, like open jdk or another version of jdk.
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-sun/jre/bin/java 3

Finally, run this command and type the number of the new installation then hit enter.

sudo update-alternatives --config java

To make sure everything worked, run this command. It should output your version to be 1.7.0.

java -version

And that's it! Let me know if you have problems with anything.


you can have sevral jdk, if you made a link and used update-alternatives command.
you can switch jdk very easily
java-1.6.0-openjdk java-6-sun java-7-sun

java-6-openjdk java-6-sun-1.6.0.26 jdk1.7.0_02


# Set JAVA_HOME, PATH
open profile file
#sudo gedit /etc/profile 

type it in
JAVA_HOME=/usr/lib/jvm/java-7-sun/ 
export JAVA_HOME
export PATH=$PATH:/usr/lib/jvm/java-7-sun/bin

No comments:

Post a Comment