This manual is to help install java (jdk) in Ubuntu / Debian Linux. Previously we discussed about how java’s installation has evolved over a period, then I promised to write an article on installing java on Linux. Yes I love Linux!
Before install you should be aware of couple of things.
- Which package I need to install
- Is that package already installed in my linux box
Which Package to Install?
‘Generally’ we use sun’s (oracle) jdk. If you do not have precondition on which package, then use sun’s package. FOSS equivalent alternative for sun JDK is openjdk.
To know the list of jdk packages available for you to install, use the following command:
$ dpkg-query -l '*jdk*'
Is java already installed in my linux?
$ which java
or
$ java -version
Above two commands is the easiest way to identify if java is installed in your linux. But this will work only if you have installed jdk using standard means and the path are setup correctly.
Otherwise,
- If you know the exact package name, you can use following command:
$ dpkg-query -W -f='${Status} ${Version}\n' sun-java6-jdk
in the above command, sun-java6-jdk is the package name.
If your jdk is not installed you will get the following response:
“No packages found matching sun-java6-jdk.”
or you can use the following command to get a detailed output
$ dpkg -s sun-java6-jdk
Java Installed but path not set or don’t know the path
Use the following commands to know the path of jdk installation
$ sudo updatedb $ locate java
Install Jdk
As of the time of writing this article sun’s package is not available in the partner repositories. Therefore you will not be able to do live installation using defalut repositories.

Either, you need to add additional repository to your list or download package from available site and install it offline.
Method 1: Live Install
You need a live internet connection. Run the following commands sequentially.
$ sudo apt-get install python-software-properties $ sudo add-apt-repository ppa:sun-java-community-team/sun-java6 $ sudo apt-get update $ sudo apt-get install sun-java6-jdk
Method 2: Download and Install
http://archive.canonical.com/pool/partner/s/sun-java6/
This url has list of Sun’s packages available. Download the appropriate package and use the following command:
$ sudo dpkg -i package.deb
After this, your JAVA_HOME will be:
JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.06"
Wishing you Merry Christmas!

















Nice one
Mohan on December 26th, 2011 6:55 amThis post is really helpful. Thanks and Merry Christmas..! I want to install java in Fedora. Even though Fedora has Linux kernel, I think it will be different from this. Please help in this regard.
vidyasagar on December 26th, 2011 7:09 amthis really helps…..Thanks
kishore on December 26th, 2011 1:22 pmthis is very usefull formr
nizam on December 27th, 2011 11:32 amThanks, really a good stuff.
shubham on December 29th, 2011 11:45 amUseless.
apt-get install openjdk-6-jre icedtea
Or download Java from Oracle.
craigevil on January 2nd, 2012 12:43 amAs craigevil noted.
The reference implementation of Java is not Sun Java 7 or Oracle Java 7 any more. It is OpenJDK 7, which is in the repositories now.
So no need of downloading Oracle Java, if there are no bugs in the program that relies on specific bugs in Oracle Java.
Anders on January 2nd, 2012 3:30 amOracle has recently stopped issuing the sun-java6 packages (the old packages are still available on Debian Stable). Now we can either use openjdk (6 or 7) or the binary from Oracle’s site http://www.java.com.
R S Chakravarti on January 2nd, 2012 5:42 pmThanks ..i will install in my system right now.
JavabynataraJ on January 5th, 2012 12:35 pmHi, thanks for the write-up.
I had to do two more things to get it to work on Debian (wheezy) changing sourceslistd in /usr/lib/python2.6/dist-packages/softwareproperties/ppa.py to sourceslistd = apt_pkg.config.find_dir(“Dir::Etc::sourceparts”)
Torstein Krause Johansen on January 11th, 2012 4:56 amas well as purging my old Debian packages before using the PPA ones. I’ve summarised it all here: http://tkj.freeshell.org/bytes/2012/01/11/installing-sun-java-on-debian-after-it-was-removed-from-the-official-repositories/
The words comes from my heart, this is the information, i am looking for over a long period!!
vignesh on January 19th, 2012 8:36 pmthanks…
I like your effort for this blog..keep it up.This is very nice blog and can know more things about Java..
Kishore on January 27th, 2012 1:35 pmActually, i too have a thought to install linux in my machine. After that i will follow your steps to install java in to that.
Thanks.
GeekDude on February 16th, 2012 7:51 pm