How to install Java on Ubuntu Linux
Up until very recently (like last week) Java was easily installable from the hoary-extras repository for Ubuntu. However, for “legal reasons” this has stopped which has meant that installing Java is now a quick command line activity. Being a RPM-guy and new to Debian distros, I spent an hour or so searching for the right commands. The answer is available on the Ubuntu Wiki a fantastic knowledge resource and repeated below. So here are the steps to install Java on Ubuntu Linux.
How to install Java
From https://wiki.ubuntu.com/RestrictedFormats
This method will get you the latest version from Sun and also works better for most applications is to install the Sun version of Java.
Go to http://java.sun.com/j2se/1.5.0/download.jsp and click on “Download JRE 5.0 Update 4â€. Ensure you do not choose the link with the NetBeans bundle.
You must first accept the licence, then click on “Linux self-extracting file†(sun-j2re1.5_1.5.0+update04_i386). Save this file to your hard drive.
Make the downloaded file executable. At the command line, change to the directory where you downloaded the file, and type
chmod +x sun-j2re1.5_1.5.0+update04_i386.bin
To install JRE, run the downloaded file. Type
fakeroot make-jpkg sun-j2re1.5_1.5.0+update04_i386.bin
sudo dpkg -i sun-j2re1.5_1.5.0+update04_i386.deb
Note: If you receive these errors: ‘fakeroot: command not found’ or ‘bash: make-jpkg: command not found’. Then you need to install these tools, which you can do by simply: sudo apt-get install fakeroot make-jpkg
Open a terminal console and type:
java -version
The response should be something like:
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04)
Java HotSpot(TM) Client VM (build 1.5.0_04, mixed mode, sharing)
If the response is *not* the Java(TM) 2 Runtime Environment (official Sun Java) then the system already has the Java open source alternative installed and it is the default JVM. To change the default JVM is *really very simple*.
Selecting the default Java version
In Breezy, if you want to use Sun Java instead of the open source GIJ you need to set it as default. Run:
sudo update-alternatives --config java
and select your preference from the list
{i} Note: To get common java applications (installed using .deb-packages) to run under your JVM of choice, make sure you also edit /etc/jvm accordingly. Packages such as ant uses this file to determine which JVM to start.
For more details on installing newer versions of Java and other restricted format software, such as MP3, DVD players etc. read https://wiki.ubuntu.com/RestrictedFormats






