Installing Java on your Linux system

Vincent Danen shows the easiest way to install Java on a Linux system.

Java is a fairly important technology to have on any operating system. Countless Web sites make use of Java or JavaScript; programs such as Zend Studio are Java applications that require the Java Runtime Environment; and many developers develop in Java.

Unfortunately, most Linux distributions do not ship with Java due to its license fee. Certain Java implementations are free, such as GCJ, or the GNU Compiler for Java, but it isn't Sun's Java implementation, which is arguably the better of the two.

Luckily, installing Java on your Linux system is extremely simple. Visit the Java download Web site and select the operating system you'd like to download for (Linux, Linux AMD64, Solaris, etc.). Once you've chosen the download file--either a self-extracting executable or a self-extracting RPM file--you can install it. In this case, the latest version is version 5.0 Update 5 and uses the self-extracting binary:


# mkdir -p /usr/local/java

# cd /usr/local/java

# mv /path/to/jre-1_5_0_05-linux-amd64.bin .

# chmod u+x jre-1_5_0_05-linux-amd64.bin

# ./jre-1_5_0_05-linux-amd64.bin


The installation must be done as root if you want the Java installation to be site-wide; if you want it just for yourself, you can extract the package in ~/bin/java or some other appropriate location. In the above, the JRE is installed in /usr/local/java/jre1.5.0_05/.

As a quick test, run the java executable:


# cd jre1.5.0_05/bin

# ./java -version


To make Java available to all users, add it to the default PATH settings by editing /etc/profile and adding: