Pages

Tuesday, June 12, 2012

How to manual install Java on Ubuntu

In today’s post, I’m going to show you how to manual install Oracle Java (JDK) 7 on Ubuntu without using PPA. There are several ways to install Java on Ubuntu. In this post I'm going to show  you install Java on Ubuntu without using PPA.

1. Download Java Development Kit from this link from

2. After downloading jdk extract the downloaded package by running the commands
    below. This assumes that the package was downloaded in your Downloads folder.

tar -xvf /home/mahesh/Downloads/jdk-7u4-linux-i586.tar.gz






3. JDK 7 package is extracted into ./jdk1.7.0_04 directory. Now move the JDK 7 directory to /usr/lib

sudo mv /home/mahesh/Downloads/jdk1.7.0_04 /usr/lib/jvm/jdk1.7.0






4. Next run the following commands on terminal one by one

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






5. Next run the following command on terminal

sudo update-alternatives --config java






You will see output similar one below - choose the number of jdk1.7.0 - for example 3 in this list.

$sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide
/usr/bin/java (java)
*There have no list don't worry. It says no alternative jdk on your computer. It automatically updated current installed jdk.

6. Check the version of you new installation.







7. Run following code on terminal

sudo update-alternatives --config javac
sudo update-alternatives --config javaws







*There has no list don't worry. It says no alternative jdk on your computer. It automatically updated current installed jdk. But there hava a list to select alternative choose the number of jdk1.7.0

8. Now you finish install Oracle JDK on your computer.

1 comment:

  1. Very useful and interesting article... i am working as a java developer, and want to learn more Java Training to learn new professional techniques in java, your article helps me to clear my doubt as well, keep rocks and sharing more article...

    ReplyDelete