Tuesday, April 21, 2015

How to install OpenJDK on CentOS/RHEL

P
OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java Platform, Standard Edition (Java SE).[1] It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GNU GPL) with a linking exception. Were it not for the GPL linking exception, components that linked to the Java class library would be subject to the terms of the GPL license.

Currently, there is supported OpenJDK6, OpenJDK7, OpenJDK8. This article will show you how to install these.

Find out which version is available

[root@localhost Desktop]# yum search openjdk

Output

[root@localhost ~]# yum search openjdk
Loaded plugins: fastestmirror, refresh-packagekit, security
base                                                     | 3.7 kB     00:00
base/primary_db                                          | 3.6 MB     00:00
extras                                                   | 3.4 kB     00:00
extras/primary_db                                        |  29 kB     00:00
updates                                                  | 3.4 kB     00:00
updates/primary_db                                       | 2.6 MB     00:01
============================= N/S Matched: openjdk =============================
java-1.6.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.i686 : OpenJDK Demos
java-1.6.0-openjdk-devel.i686 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.i686 : OpenJDK API Documentation
java-1.6.0-openjdk-src.i686 : OpenJDK Source Bundle
java-1.7.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.i686 : OpenJDK Demos
java-1.7.0-openjdk-devel.i686 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.i686 : OpenJDK Source Bundle
java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk-demo.i686 : OpenJDK Demos
java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle
icedtea-web.i686 : Additional Java components for OpenJDK - Java browser plug-in
                 : and Web Start implementation

  Name and summary matches only, use "search all" for everything.

Installing OpenJDK 6

In your terminal, type this command to install OpenJDK 6 and OpenJRE 6 respectively

[root@localhost Desktop]# yum install java-1.6.0-openjdk-devel java-1.6.0-openjdk

After installation finished, check your machine that has been installed OpenJDK6

[root@localhost Desktop]# java -version

Output

[root@localhost ~]# java -version
java version "1.6.0_35"
OpenJDK Runtime Environment (IcedTea6 1.13.7) (rhel-1.13.7.1.el6_6-i386)
OpenJDK Client VM (build 23.25-b01, mixed mode)
OpenJDK is installed in /usr/lib/jvm/java, therefore, you can set your JAVA_HOME with this path
# export JAVA_HOME=/usr/lib/jvm/java
Installing OpenJDK 7

Type this command to install OpenJDK 7 and OpenJRE 7 respectively

[root@localhost Desktop]# yum install java-1.7.0-openjdk-devel java-1.7.0-openjdk

After installation finished, check your machine that has been installed OpenJDK 7

[root@localhost Desktop]# java -version

Output

[root@localhost ~]# java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (rhel-2.5.5.1.el6_6-i386 u79-b14)
OpenJDK Client VM (build 24.79-b02, mixed mode, sharing)
OpenJDK is installed in /usr/lib/jvm/java, therefore, you can set your JAVA_HOME with this path
# export JAVA_HOME=/usr/lib/jvm/java
Installing OpenJDK 8

Type this command to install OpenJDK 8 and OpenJRE 8 respectively

[root@localhost Desktop]# yum install java-1.8.0-openjdk-devel java-1.8.0-openjdk

After installation finished, check your machine that has been installed OpenJDK 8

[root@localhost Desktop]# java -version

Output

[root@localhost ~]# java -version
openjdk version "1.8.0_45"
OpenJDK Runtime Environment (build 1.8.0_45-b13)
OpenJDK Server VM (build 25.45-b02, mixed mode)
OpenJDK is installed in /usr/lib/jvm/java, therefore, you can set your JAVA_HOME with this path
# export JAVA_HOME=/usr/lib/jvm/java

No comments:

Post a Comment