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.
‘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*'
$ 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,
$ 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
Use the following commands to know the path of jdk installation
$ sudo updatedb $ locate java
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.
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
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!
Comments are closed for "Install Java in Linux (Ubuntu / Debian)".
Nice one
This 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.
this really helps…..Thanks
this is very usefull formr
Thanks, really a good stuff.
Useless.
apt-get install openjdk-6-jre icedtea
Or download Java from Oracle.
As 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.
Oracle 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
Thanks ..i will install in my system right now.
Hi, 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”)
as well as purging my old Debian packages before using the PPA ones.
The words comes from my heart, this is the information, i am looking for over a long period!!
thanks…
I like your effort for this blog..keep it up.This is very nice blog and can know more things about Java..
Actually, 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.
please I have a problem in the install,
the following message:
E: Couldn’t find package sun-java6-jdk
what can I do?
Thanks a lot. I just installed java in my system.
Is there any way to install java without using the terminal and also how to install java if the tar.gz file is already downloaded