Java setup in Linux




Java Setup in RHEL, CentOS, and Oracle Linux

Download the rpm package from Oracle, example: jdk-7u25-linux-x64.rpm

Uninstall previous version:
# yum erase jre*

Install:
# yum install jdk-7u25-linux-x64.rpm

Verify:

# java -version
java version “1.7.0_25″
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

# ls -l /usr/java/
lrwxrwxrwx. 1 root root 16 Sep 3 15:33 default -> /usr/java/latest
drwxr-xr-x 8 root root 4096 Sep 4 09:21 jdk1.7.0_25
drwxr-xr-x. 6 root root 4096 Sep 3 15:33 jre1.7.0_25
lrwxrwxrwx 1 root root 21 Sep 4 09:21 latest -> /usr/java/jdk1.7.0_25

How to remove other java versions using alternatives:

# alternatives --config java

There are 3 programs which provide 'java'.
Selection Command
———————————————–
1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
2 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
*+ 3 /usr/java/default/bin/java

# alternatives –remove java /usr/lib/jvm/jre-1.5.0-gcj/bin/java
# alternatives –remove java /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

# alternatives --config java
There is 1 program that provides 'java'.

Selection Command
———————————————–
*+ 1 /usr/java/default/bin/java

 

Adding Java to Firefox:

For all users:

# cd /usr/lib64/mozilla/plugins/
# ln -s /usr/java/jdk1.7.0_25/jre/lib/amd64/libnpjp2.so
# ls
# libnpjp2.so -> /usr/java/jdk1.7.0_25/jre/lib/amd64/libnpjp2.so

For single user:

$ cd /home/username/.mozilla/plugins/
$ ln -s /usr/java/jdk1.7.0_25/jre/lib/amd64/libnpjp2.so

A java webstart (javaws) is use to launch a .jnlp file, example:
$ javaws ~/Downloads/launch.jnlp


Published by

Ferdy Mañago

Portland, Oregon