How to install Java on Linux Ubuntu – Tutorial

Important Note: See updated information below.

This is a tutorial for beginners. Just open console and run following commands:

Java 6 installation:


sudo add-apt-repository ppa:ferramroberto/java

sudo apt-get update


sudo add-apt-repository ppa:sun-java-community-team/sun-java6

sudo apt-get update

sudo apt-get install sun-java6-jre sun-java6-bin sun-java6-jdk sun-java6-fonts[/java]

Use Java 6 as default:

[java]sudo update-alternatives --config java[/java]

Select: /usr/lib/jvm/java-6-sun/jre/bin/java

Firefox Java plugin installation:


[java]cd /usr/lib/mozilla/plugins

sudo ln -s /usr/lib/jvm/java-6-sun/jre/lib/amd64/



[java]cd /usr/lib/mozilla/plugins

sudo ln -s /usr/lib/jvm/java-6-sun/jre/lib/i386/


Have a nice day.


No problem! :slight_smile: If someone knows how to install Java 6 to Fedora it would be cool to post here too.

great! wish this was around a few weeks ago when I sunk a few hours into trying to get it up and running :slight_smile:

none of these commands work for me:

sudo update-java-alternatives -s java-6-sun

sudo update-alternatives –config java

Select: /usr/lib/jvm/java-6-sun/jre/bin/java

sudo update-alternatives –install /usr/lib/mozilla/plugins/ /usr/lib64/jvm/java-6-sun/jre/lib/amd64/ 50

Basically they say there are no alternatives and that -config and -install are unknown arguments. When I try to run jMonkey it locks up.



html works incorrrectly. Thanks for your answer. I updated my topic. Have a try again, please.

ok, got all of them but the last one, I am wondering if it is due to the AMD64 in the path?

Thanks again!


amd64 is only for 64 bit OS. If you have a 32 bit OS you must use a different command for that one.

1 Like

Thanks! I added 32bit and 64bit versions for firefox plugin.

hmm, now I am getting this error:

“update-alternatives: --install needs link> name> path> priority>” (I removed the “<” so they would show up)

Thanks again for all the help! :slight_smile:

Evidently the PPA linked to in this thread is an older version which has not fixed certain security vulnerabilities. Oracle has released a newer version but you wont find it in the repositories (evidently licensing issues). You can get it from the oracle website. I found these instructions to be useful: How To Install Oracle Java 7 (JDK) In Ubuntu ~ Web Upd8: Ubuntu / Linux blog

Also note while this sets ajva to the oracle jvm javaws is still using openjdk (or whatever stuff was installed)

This can lead to some confusion if you are not aware of it.