[FrontPage] [TitleIndex] [WordIndex

This is a read-only archived version of wiki.centos.org


DRAFT This page is still under CONSTRUCTION

How to install the Java Development Kit from Java.com

A full Java development environment can be obtained by using the Oracle (formerly Sun) Java Development Kit (JDK) RPMs on all currently supported CentOS versions. 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.

1. Java i386 JDK 1.6

  1. Download Linux RPM (Linux x86 - RPM Installer) jdk-6u27-linux-i586-rpm.bin from Oracle

  2. Follow the instructions from Becoming Root in order to become root and install the package:

    # cd [download directory]
    # sh ./jdk-6u27-linux-i586-rpm.bin
    During this step several rpm packages will be extracted from jdk-6u27-linux-i586-rpm.bin and they will be installed.
  3. Install java, javaws, libjavaplugin.so (for Firefox/Mozilla) and javac using the alternatives –install command:
    • 3.1 Start by retrieving the current situation:
      # 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.4.2-gcj/bin/java
      Enter to keep the current selection[+], or type selection number:
    • 3.2 Install the needed commands using the alternatives system. In order to achieve that, note the number of already installed versions N and use N+1 as the last parameter of the following commands (if there is no output from the command run in step 3.1, just imagine that N was 0) - For instance, using the example above where 2 versions were installed , we will use 3 for the new version:

      # alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_27/jre/bin/java 3 \
       --slave /usr/bin/javaws javaws /usr/java/jdk1.6.0_27/jre/bin/javaws \
       --slave /usr/lib/mozilla/plugins/libnpjp2.so libnpjp2.so /usr/java/jdk1.6.0_27/jre/lib/i386/libnpjp2.so \
       --slave /usr/bin/javac java /usr/java/jdk1.6.0_27/bin/javac \
       --slave /usr/bin/jar jar /usr/java/jdk1.6.0_27/bin/jar

      (If you want to verify the existing slave settings you can use alternatives --display java)

  4. Activate the newly installed version:
    # 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.4.2-gcj/bin/java
       3           /usr/java/jdk1.6.0_27/jre/bin/java
    Enter to keep the current selection[+], or type selection number: 3   //<--
    # java -version
    java version "1.6.0_27"
    Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
    Java HotSpot(TM) Client VM (build 20.2-b06, mixed mode, sharing)

    Make sure you select (<--) the same value as the one that you have used for the install command.

2023-09-11 07:22