Java on CentOS
From DTO Labs Knowledge Base
The easiest way to get Java installed on CentOS is to use the OpenJDK included in the distribution.
Setup
- Install the full JDK using Yum:
[root@ip-10-170-26-209 ~]# yum -y install java-1.6.0-openjdk-devel . . . Installed: java-1.6.0-openjdk-devel.x86_64 1:1.6.0.0-1.7.b09.el5 Dependency Installed: java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.7.b09.el5 Complete!
Test
- Check that Java is there:
[root@ip-10-170-26-209 ~]# java -version java version "1.6.0" OpenJDK Runtime Environment (build 1.6.0-b09) OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)
- Find the JAVA_HOME (for the full JDK) if you dare!:
[root@ip-10-170-26-209 ~]# which java /usr/bin/java [root@ip-10-170-26-209 ~]# ls -l /usr/bin/java lrwxrwxrwx 1 root root 22 Sep 22 10:40 /usr/bin/java -> /etc/alternatives/java [root@ip-10-170-26-209 ~]# ls -l /etc/alternatives/java lrwxrwxrwx 1 root root 46 Sep 22 10:40 /etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java [root@ip-10-170-26-209 ~]# ls -l /usr/lib/jvm total 4 lrwxrwxrwx 1 root root 26 Sep 22 10:40 java -> /etc/alternatives/java_sdk lrwxrwxrwx 1 root root 32 Sep 22 10:40 java-1.6.0 -> /etc/alternatives/java_sdk_1.6.0 drwxr-xr-x 6 root root 4096 Sep 22 10:40 java-1.6.0-openjdk-1.6.0.0.x86_64 lrwxrwxrwx 1 root root 33 Sep 22 10:40 java-1.6.0-openjdk.x86_64 -> java-1.6.0-openjdk-1.6.0.0.x86_64 lrwxrwxrwx 1 root root 34 Sep 22 10:40 java-openjdk -> /etc/alternatives/java_sdk_openjdk lrwxrwxrwx 1 root root 21 Sep 22 10:40 jre -> /etc/alternatives/jre lrwxrwxrwx 1 root root 27 Sep 22 10:40 jre-1.6.0 -> /etc/alternatives/jre_1.6.0 lrwxrwxrwx 1 root root 37 Sep 22 10:40 jre-1.6.0-openjdk.x86_64 -> java-1.6.0-openjdk-1.6.0.0.x86_64/jre lrwxrwxrwx 1 root root 29 Sep 22 10:40 jre-openjdk -> /etc/alternatives/jre_openjdk [root@ip-10-170-26-209 ~]# ls -l /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64 total 16 drwxr-xr-x 2 root root 4096 Sep 22 10:40 bin drwxr-xr-x 3 root root 4096 Sep 22 10:40 include drwxr-xr-x 4 root root 4096 Sep 22 10:40 jre drwxr-xr-x 2 root root 4096 Sep 22 10:40 lib [root@ip-10-170-26-209 ~]# export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64