Install Java On Ubuntu

21 09 2007

It is so easy to install Java on Ubuntu now. On Ubuntu 7.04 (Feisty Fawn), follow these steps:

1) Make sure you have the right repositories on your sources.list file.

Edit your sources.list file the following way:

sudo gedit /etc/apt/sources.list

or if you are not using gnome (e.g. you are logged in through ssh):

sudo nano /etc/apt/sources.list

If the following lines are not already there, add them:

deb http://us.archive.ubuntu.com/ubuntu feisty main restricted
deb http://us.archive.ubuntu.com/ubuntu feisty universe multiverse

Save the file (in nano use Control-O to save and then Control-X to exit).
Now you need to tell the package manager to update it’s database:

sudo apt-get update

2) Install Java using apt-get

I currently have both Java 5 and Java 6 installed on my machine and it’s very easy to switch between the two. Java 6 has some nice goodies such as JSR-223 and better jconsole that I like to use.

For Java 5:

sudo apt-get install sun-java5-jre sun-java5-jdk sun-java5-plugin

For Java 6:

sudo apt-get install sun-java6-jre sun-java6-jdk sun-java6-plugin

There are other packages that you might be interested in:

  • sun-java6-demo
  • sun-java6-doc
  • sun-java6-source

3) Verify installation

Verify that you have the correct version of java running:

java -version

For example, on my machine (yes, I call it tiwouj):

Ubuntu Java Version

To see a list of the java versions that you have installed, you can use the following command (it’s a letter L at the end of the command):

update-java-alternatives -l

Here is my list:

Ubuntu Java List

This should show you a list of all the java alternatives you have installed. java-gcj is the free version of Java from the GNU project and comes installed by default with Ubuntu so you should see it. To switch to a different version, use the following command:

sudo update-java-alternatives -s <version-desired>

e.g:

sudo update-java-alternatives -s java-1.5.0-sun

Make sure it worked:

java -version

That’s it! How easy was that? You have to love apt-get.


Actions

Information

7 responses to “Install Java On Ubuntu”

19 10 2007
Fred Horton (13:16:44) :

Hi Luc — thanks for the help installing Java etc. — worked like a charm.

Regards,
Fred

24 10 2007
Juan (17:57:21) :

Dude.. Thanks for the help.. :) You rock. Seriously. :D

21 12 2007
JohnI (16:36:44) :

This article helped quite a bit. Thank you. Very clear and direct.

11 03 2008
Sidu (05:46:16) :

Thanks Bro. it really works…
i was trying to download java but my computer was giving some problems…
but manually like this… it really worked. thanks again….

29 05 2008
josephine (16:07:53) :

thanks a lot. I am loving ubuntu each day.

18 06 2008
fstyle.de (23:56:12) :

Install java on ubuntu / switch verisons…

I am a linux noob. So what?
Here is what I found searching the net how to switch java versions on Ubuntu:

It is so easy to install Java on Ubuntu now. On Ubuntu 7.04 (Feisty Fawn), follow these steps:

1) Make sure you have the right repositories…

23 06 2008
Install java on ubuntu / switch verisons (07:45:05) :

[...] (source) [...]

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>