This article explains how to install Java SDK and/or Java Runtime in Debian, Ubuntu, Fedora, Red Hat, Gentoo, and Slackware Linux.
In November 2006, Sun Microsystems released Java under the GPL license. Since then the Java Development Kit (JDK) is now known as OpenJDK (Code name IcedTea).
Sun Microsystems has since been acquired by Oracle Corporation. And Java is now maintained by Oracle. OpenJDK is mostly a rebranded version of Oracle's JDK, so it naturally implements almost all of Oracle Java features.
Install Java in Debian
You can install OpenJDK in Debian as follows.
# apt-get install openjdk-6-jdk
Install only the Java Runtime Environment (JRE) as follows.
# apt-get install openjdk-6-jre
In Ubuntu, instead of logging in as root user, you should use SUDO to execute the above commands.
Install Java in Fedora
Fedora or Red Hat Linux use RPM package manager for software management. Here is how you install Java in Fedora Linux.
You can install the Java Runtime Environment (JRE) as follows.
$ su -c "yum install java-1.6.0-openjdk"
To develop Java programs in Fedora, you also need to install the OpenJDK development packages as shown below.
$ su -c "yum install java-1.6.0-openjdk-devel"
To run Java applets in web browser, you should also install
$ su -c "yum install icedtea-web"
If you installed Fedora using the DVD image, then you don't have to do any thing as OpenJDK runtime and development packages are installed by default.
You can also install alternate Java packages including free and non-free ones in Fedora from JPackage.org.
Install Java in Gentoo
How to install Java in Gentoo is explained in detail at gentoo.org/doc/en/java.xml.
Install Java in Slackware
As of this writing, there is no official Slackware package for Java.
To install Java in Slackware, you can do one of the two things.
- Download and install the Java runtime and JDK binaries from Oracle's Java website. Or
- Use an unofficial Slackware package build for OpenJDK as explained here.
Points to note
Before you decide to install Java in Linux, you should be aware of a few things.
There are different implementations of Java and JRE. The popular among them are -
- The IcedTea Open Java SE
- Oracle's Java 7 SE
- Sun's Java 6 SE, and
- The IBM Java SE
You can install all these Java implementations in Linux simultaneously and switch between them.
Check the version of Java on your machine
$ java -version
Test if Java is working perfectly on your computer
To test your installation of Java, open your web browser and visit this web page. It contains a Java applet. If the applet loads properly, it means the Java installed on your machine is working properly.