So, you play a lot of online games, or use a web app that needs Java. You know that version “X” is available in the Ubuntu repositories, but when you check out the Java.com website you see that version “X+1” is available. How do you install the newer version? There are instructions available on the Java.com website, but they’re kind of spread out and vary slightly, depending on which version of certain programs you’re using. So here, for Ubuntu users, is how to install the shiniest new version of Java on your 32-bit computer, including the browser plugin.
Note: this set of instructions may well work for other Linux distros and web browsers, but since I know it works for Firefox and Ubuntu (the 32-bit version), that’s how I’m describing the process.
Step One – Download Java
Go to Java.com and download the file called “Linux (self-extracting file). You can do this simply by clicking the link and choosing a download spot.
Step Two – Make Java Executable
Before you can use the file you just downloaded, you need to let your computer know the file can be loaded as a program (made executable). To do this, type the following into the Terminal:
sudo chmod a+x jre-6u21-linux-i586.bin
The above command works for the newest version as I type this, but as things change, the file name will also change, so vary the command according to the actual name of the file downloaded.
Step Three – Create and Move To The Installation Directory
If you want Java installed just for yourself, you can create a Java folder in your home directory (or any other place you have write permissions), but if you want everyone on the computer to be able to use Java, I’d recommend installing it in the /usr/ folder. To accomplish that, you’ll first create a new Java directory, then move to it. That’s two commands in the Terminal (the first creates the new directory, the second moves you to it:
sudo mkdir /usr/java/
Step Four – Run the installer
You’ll now need to run the installer, which places all the bits in the right spots. If you’ve already had a version of Java installed on your system, you may not see the User Agreement. If this is the first time, however, you’ll need to scroll through it (the agreement is long, probably 8-10 “pages” in the Terminal). Once through it, agree and the installation continues. When it’s finished, you should see “Done” in the Terminal. To start the installation process, type:
Note the command above, and the whole “/the/path/to/the/installer” part. This obviously changes based on where you downloaded the file. Because of this, and to make things simpler, I always move the file itself into the Java directory, and then delete it when the installation is finished. So for me, I would use two commands (and note that I usually download things to my Desktop):
sudo mv /home/ericcflem/Desktop/jre-6u21-linux-i586.bin /usr/java/
Step Five – Delete the installer
Once this is accomplished you may delete the installer. If you never moved the installer file and it is still wherever you downloaded it (home directory, Desktop, downloads folder), you can simply move it to the trash, or if you used my “alternate” steps in Step Four, you can type this into the Terminal (the command assumes you are still in the /usr/java/ directory):
sudo rm jre-6u21-linux-i586.bin
Step Six – Make The New Java The Java Your System Uses
If you have applications installed that run on Java, you’ll want them to still operate, correct? Linux keeps a list of all the options you have on your computer that can accomplish the same task, so if you have four text editors installed, it knows which one to launch when you double-click a TXT file. Similarly, you might have the official repositories Java installed, as well as the one you just manually installed. Do let your system know you want the new Java to be the one that gets used, do the following (all steps are necessary if this is the first Java you’ve installed, but might not be necessary if you’ve already had a Java runtime installed, but I always do both commands, just to be sure):
sudo update-alternatives –install “/usr/bin/java” “java” “/usr/java/jre1.6.0_21/bin/java” 1
After this, I’m asked for my password, then receive notice that the new Java will be used in auto mode. So far, so good. Now type this:
sudo update-alternatives –set java /usr/java/jre1.6.0_21/bin/java
From now on, any program you have installed that runs on Java will use the new version. Okay, only one step left:
Step Seven – Firefox or Mozilla Browser Plugin
You will, of course, want to play Java games on the Web, right? To do this, we need to let link the new plugin to your Firefox or Mozilla plugins directory. The following will absolutely depend on what version of Firefox you’re using. The first thing to do is navigate to the Firefox/Mozilla installation plugins directory. It’s probably someplace like “/usr/lib/firefox/plugins/” so to navigate there do the following:
Once you’ve done that, you’ll need to place a link in the plugins directory to the actual Java plugin (located in the new Java installation directory). Depending on which version of Firefox you have installed, one of the following should do it for you. For older versions of Firefox, type:
sudo ln -s /usr/java/jre1.6.0_21/plugin/i386/ns7/libjavaplugin_oji.so
For newer versions (why this isn’t listed on the Java website I don’t know!), you’ll need to type the following command, which links to a different file:
sudo ln -s /usr/java/jre1.6.0_21/lib/i386/libnpjp2.so
Once you’ve done this, open up Firefox (if it was open during this process, close it and restart it so it “sees” the new plugin), and type the following in the address bar:
You should now see a list of all the plugins you have installed on your computer for Firefox to use. Java should be one of them. Congrats!