Saturday, September 29, 2012

Installing Oracle JDK on Ububtu 12.04 and openSuse 12.2

Ubuntu and openSuse both come with openJDK installed, however at times one needs Oracle JDK to be present in the system. Here are the steps needed to install it on both OS.

1. Download Oracle JDK  fron oracle site Download Oracle JDK. These instrction are for 

Java SE 6 Update 35.

2. Copy it to "/usr/lib/jvm" directory
# cp jdk-6u35-linux-i586.bin /usr/lib/jvm
3. Make it executable and run it
 # chmod +x jdk-6u35-linux-i586.bin
# ./jdk-6u35-linux-i586.bin
It shall unzip itself and create directories.

4. Install it in alternatives system
# sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_35/bin/java 1 
 # sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_35/bin/javac 1
 # sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_35/bin/javaws 1
 Here is what update-alternatives' man page says about installing
update-alternatives  --install <link> <name> <path> <priority>

5. Now select it as default by running these commands and select the JDK
# sudo update-alternatives --config java
# sudo update-alternatives --config javac
# sudo update-alternatives --config javaws 
6. Create plugin link
# sudo ln -s /usr/lib/jvm/jdk1.6.0_35/jre/lib/i386/ /usr/lib/mozilla/plugins
7. Now test it with version
# java  -version
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10)
Java HotSpot(TM) Client VM (build 20.10-b01, mixed mode, sharing)

For openSuse all above is same except these enviornment variables needs to be put in "/etc/profile"

export JAVA_HOME=//usr/lib/jvm/jdk1.6.0_35/
export JAVA_BINDIR=//usr/lib/jvm/jdk1.6.0_35/bin/
export JAVA_ROOT=//usr/lib/jvm/jdk1.6.0_35/
export JDK_HOME=//usr/lib/jvm/jdk1.6.0_35/
export JRE_HOME=//usr/lib/jvm/jdk1.6.0_35/

Some software like jEdit use  these variables to detect Java.

Though these instructions are for Ubuntu and openSuse, they might work for other distros.

Hope this helps as I got from other sources.

Thanks for reading.


  1. NICE BLOG!!! Thanks for your valuable information, It would be really helpful for us, and I was looking for this. Thanks and keep sharing..
    mobile app development

    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.