How to install the Java Runtime Environment from Java.com

If a browser plugin and Java runtime are all that is required, as opposed to a full Java development environment, the Oracle (formerly Sun) Java Runtime Environment (JRE) RPMs work for all currently supported CentOS versions, and are arguably the most compatible with web pages that require a Java plugin. The Java versions shown below are current as of this writing. Always use the latest available version for your architecture (i386 32-bit or x86_64/amd64 64-bit) and adjust accordingly.

Java 1.7 and Java 1.8 are now available, while Java 1.6 has been deprecated. However the same procedure as below can be used with any of them. The only difference is that the new versions are distributed directly as a rpm package so instead of the shell command which unpacks and installs the ".bin" package, simply use yum to install the downloaded rpm package, just as you would install any other rpm; for instance: yum install ./jre-8u11-linux-i586.rpm

 

Java i386 JRE and plugin

Due to the way the libraries bundled in the package were built, the browser plugin included in Java 1.7 >= 1.7.0.65 no longer works on CentOS 5. The package can be sucessfully installed but firefox will not enable the plugin due to missing GLIBC symbols. Please use the plugin from Java 1.8 instead.

Download the latest Linux RPM (self-extracting file), currently jre-6u30-linux-i586-rpm.bin, from java.com then as root install and configure the alternatives system and plugins.

 

# cd [download directory]
# sh ./jre-6u30-linux-i586-rpm.bin
# alternatives --config java
There are 2 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
Enter to keep the current selection[+], or type selection number:

Note number of versions, N, and use N+1 (if there is no output from the previous command, just imagine that N=0) – For example, if 2 versions were installed then:

 

# alternatives --install /usr/bin/java java /usr/java/latest/bin/java 3
# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
   3           /usr/java/latest/bin/java
Enter to keep the current selection[+], or type selection number: 3
# java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

Create links in the Mozilla Plugins directory so Java will work in supported browsers such as Firefox.

 

# cd /usr/lib/mozilla/plugins/
# ln -fs /usr/java/latest/lib/i386/libnpjp2.so

Skip to the section on testing the browser plugin.

 

Java x86_64 JRE and plugin

Download the latest Linux RPM (self-extracting file), currently jre-6u30-linux-x64-rpm.bin, from java.com then as root install and configure the alternatives system and plugins:

 

# cd [download directory]
# sh ./jre-6u30-linux-x64-rpm.bin
# alternatives --config java
There are 4 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   2           /usr/java/jre1.6.0_13/bin/java
   3           /usr/java/jre1.6.0_18/bin/java
*+ 4           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
Enter to keep the current selection[+], or type selection number:

Note number of versions, N, and use N+1 (if there is no output from the previous command, just imagine that N=0) – For example, if 4 versions were installed then:

 

# alternatives --install /usr/bin/java java /usr/java/latest/bin/java 5
# alternatives --config java
There are 5 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   2           /usr/java/jre1.6.0_13/bin/java
   3           /usr/java/jre1.6.0_18/bin/java
*+ 4           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   5           /usr/java/latest/bin/java
Enter to keep the current selection[+], or type selection number: 5
# java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_30)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

Create links in the Mozilla Plugins directory so Java will work in supported browsers such as Firefox.

 

# cd /usr/lib64/mozilla/plugins/
# ln -fs /usr/java/latest/lib/amd64/libnpjp2.so

 

Test browser

Exit Firefox if it is running and [re]start Firefox. Type "about:plugins" in the URL field. It should show Java enabled.

Verify installed version at Java.com, Test installed version at Java.com or at javatester.org.

 

Remove old versions

Oracle recommends removing old Java versions as they represent a security risk if left installed. By default, the installation procedure above will not remove old versions so we must do this manually:

 

# rpm -qa jre\*
jre-1.6.0_13-fcs.x86_64
jre-1.6.0_18-fcs.x86_64
jre-1.6.0_30-fcs.x86_64
# rpm -e jre-1.6.0_18-fcs.x86_64 jre-1.6.0_13-fcs.x86_64

 


 

  • Java is a trademark of the Oracle Corporation.

 


 

  • This page created and maintained by PhilSchaffner. Other Wiki contributors are invited to make corrections, additions, or modifications.

HowTos/JavaRuntimeEnvironment (last edited 2014-08-05 13:18:58 by ManuelWolfshant)

Leave a Reply

Your email address will not be published. Required fields are marked *