Let's face it, although most operating systems don't install Java by default, there are many applications that rely on this tool. The reasons for OSes to not install Java are many (mostly of the licensing flavor) and, at least with Linux, the installation process can be confusing (at best) or painful (at worse). To begin with - which do you install? You can install jdk, jre, blackdown...the list goes on and on. And do you install from the downloadable binary installer or is there a better way.
I am here to tell you, at least with Ubuntu 10.04, there is a simple way of installing Java. That's is the purpose of this article. Of course I will also take this one step further and show you how to make Firefox aware of your java installation. With this installed you can go ahead and visit those java-is-required web sites, as well as build those web applications you need to serve up.
We are going to be installing Java with the help of apt-get so, as you can guess, we will be doing this from the command line. So fire up your favorite terminal window and get ready to work.
The first step is to add the necessary repositories to the /etc/apt/sources.list file. So open that file up with your favorite text editor and add the following line to the bottom of that file:
deb http://archive.canonical.com/ lucid partner
Now to update apt, issue the command:
sudo apt-get update
Once apt has completed its update, you are ready to install. The actual installation command is:
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
The above command should install everything you need for you to get your java on. During the installation you may have to "read" and "agree" to the licensing of the software. Do this or the installation will exit without completing. Once the installation is complete you are done. Right? Maybe. But, before you assume all is complete, let's check our installation. The easiest way to test your installation is to issue the command java -version at which point you should see something like:
java version "184.108.40.206"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)
That will tell you for sure Java is installed.
Now it's time to let Firefox in on the installation. This too is simple. From the same command line you installed Java in issue the command:
The above command should return numerous results. The result you are looking for will resemble /usr/lib/jvm/java-6-sun220.127.116.11/jre/plugin/i386/ns7/libjavaplugin_oji.so. Now that you know the path you need to create a link to this in the /usr/lib/mozilla/plugins directory. First change into the plugins directory with the command cd /usr/lib/mozilla/plugins and then create the link with the command ln -s /usr/lib/jvm/java-6-sun18.104.22.168/jre/plugin/i386/ns7/libjavaplugin_oji.so. Now all you need to do is restart Firefox and then enter about:plugins in the address bar to see that Java is now enabled in your browser.
Did I say it was going to be easy? Maybe that was a slight exaggeration. I realize that installing Java on Linux isn't nearly as it is on Windows, but it is certainly do-able. And in some situations, a must do. I hope this has helped make that "do" a little more "able".
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.