Installing Sun Java on Linux

Java logo While Sun's Java platform is now almost completely open source, most distributions haven't been updated to ship with the technology (and there is a small amount of code that still isn't open source). Without Java, you could be missing out on running some applications and (less frequently now) Java applets on websites.

It is a little bit of a pain to install however, so in this tutorial I'll be showing you how to install it from Sun's website using the self-extracting installer.

So first of all, let's head on over to the site and go to the Linux Java downloads page. Let's jump there quickly however, so click on the following link -

On that page, we want the self-extracting file (and for wide compatibility, I'm not doing the RPM version in this tutorial, so choose the one below that). Let that file download. Now we'll need to head over to the terminal for a bit (I'll assume that file you downloaded is on your desktop).

I'm going to install Java into the /usr/java folder, which doesn't exist yet, so we need to login as root and create it. If you're on Ubuntu, ignore all su - commands, but remember any time you see the hash # symbol in front of a command, you'll need to prefix it with sudo. Most other distros can follow this as is:

$ su -
# mkdir /usr/java
# chmod u=rwx,g=rx,o=rx /usr/java

Now we need to copy the self-extracting installer to this new directory. In the following command, you'll need to substitute in your own username, and the exact name of the downloaded file.
# cp /home/peter/Desktop/jre-6u3-linux-i586.bin /usr/java
# cd /usr/java

One more step before we launch the installer; we need to set the permissions on it so we are allowed to execute it.
# chmod a+x jre-6u3-linux-i586.bin
# ./jre-6u3-linux-i586.bin

You'll see the licence agreement - use space to page through. Once you get to the bottom you'll be asked to type 'yes' to accept, which you have to do in order to continue.

The self-extractor will then get to work and unpack Java. Once that's done, you do have a working installation, but there are a couple of things to set up in your user for Java to 'just work' when launching Java programs.

Open up the file called .bashrc in your home folder (or the equivalent if you're not running bash), and add these lines before saving:

export JAVA_HOME="/usr/java/jre1.6.0_03"
export PATH="${JAVA_HOME}/bin:${PATH}"

Finally, to get the browser plugin working on Firefox and similar browsers, you should be able to just copy the plugin file in place like this:
# cp ${JAVA_HOME}/plugin/i386/ns7/ /usr/lib/mozilla/plugins

Phew! After that you should have a running Java installation.

Avatar for peter Peter Upfold -

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Installing Sun Java on Linux

  1. Binny V A (guest)

    # Posted on 17 October 2007 at 11:21 AM

    Very detailed install instructions are available at

  2. Ben Webb (guest)

    # Posted on 17 October 2007 at 01:58 PM

    Hi there,

    Just to point out that although sun are open sourcing Java, the official sun java contains about 4% propeitary bits (which afaik sun is still in the process of getting permission to gpl). Because it is still considered non-free, most distros won't have it in their main repos (in ubuntu, for exmample, you have to enable the propeitary repo, multiverse). For those who want to use all free software, a temporary project has been created, to replace the propeitary bits called IcedTea - .

    Hope you will add a note to your post, so that people aren't misled. Thanks, Ben

  3. Peter (guest)

    # Posted on 17 October 2007 at 10:49 PM

    Thanks for that clarification - post updated.

  4. # Posted on 22 October 2007 at 04:39 AM

    [...] You can read more here [...]

  5. # Posted on 30 January 2008 at 12:11 PM

    [...] a simple case of extracting the Zip file, and double-clicking the RSSOwl binary. You do however, need Java installed, no matter where you run [...]

  6. # Posted on 25 March 2008 at 11:43 PM

    [...] her er en nyere… [...]

Home » Articles » Installing Sun Java on Linux