When developing a Java application or a Java-based component, you first need to set up Java development environment. For that, you install JDK on your Linux system. JDK contains a collection of Java programming tools, as well as a complete Java runtime environment.
There are two options to install JDK on Linux: Oracle JDK or OpenJDK. The latter is open-source implementation of Oracle's Java SE platform. Choose either one you prefer.
Install Oracle JDK on Linux
Go to Oracle website, and click on "JDK Download" link.
On the next page, you must accept Oracle license agreement. Then download JDK according to your Linux system:
- For Non-RPM based Linux (e.g., Debian, Ubuntu, Mint): jdk-8u5-linux-i586.tar.gz (32-bit) or jdk-8u5-linux-x64.tar.gz (64-bit)
- For RPM-based Linux (e.g., CentOS, Fedora, RHEL): jdk-8u5-linux-i586.rpm (32-bit) or jdk-8u5-linux-x64.rpm (64-bit)
After downloading a JDK file, install it on your Linux system as follows.
To install Oracle JDK on CentOS, Fedora or RHEL:
To install Oracle JDK on Debian, Ubuntu or Linux Mint:
$ sudo tar xvfvz jdk-8u5-linux-<arch>.tar.gz -C /usr/java
After installation, define JAVA_HOME environment variable, and update PATH variable in your .bashrc file.
Install OpenJDK on Linux
To install OpenJDK on Debian, Ubuntu or Linux Mint, first search for an available OpenJDK package (named "openjdk-<version>-jdk") on your system:
After checking the latest version of OpenJDK, install it with apt-get:
To install OpenJDK on Fedora, CentOS or RHEL, first search for an available OpenJDK package (named "java-<version>-openjdk-devel") on your system:
After checking the latest version of OpenJDK, install it with yum:
After installing OpenJDK, the final step is to define JAVA_HOME environment variable in your .bashrc file.
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.