Installing the JDK on a RedHat Linux System

By default, RedHat Linux AS and AS4 servers don’t come with a JDK (Java Development Kit) installed on them. Depending on your install, if you run the java command you may get some sort of error message or a file not found message.

In this post I will describe how to install a JDK on your RedHat Linux server. It should also work on Fedora, however I have not tried it personally.

  1. First we need to download a JDK. I am downloading JDK 6u1 from http://java.sun.com/javase/downloads/index.jsp. Go to that page and click the Download button. On the new page that loads, we will download the Linux RPM in self-extracting file.
  2. Once you have downloaded your file, and have it placed somewhere on your Linux box (I put mine in /root/jdk), we will extract and install it. The name of the file I downloaded was jdk-6u1-linux-i586-rpm.bin.
  3. Login to your Linux box as the root user, and change directory to where you placed the jdk file that you downloaded.
  4. Make sure the file you downloaded is executable.
    chmod 755 jdk-6u1-linux-i586-rpm.bin
    
  5. Now run the file.

    ./jdk-6u1-linux-i586-rpm.bin
    
  6. A license agreement will appear on your screen displayed through the more command. Simply press the enter key until you get to the end, or just press the q key to skip right to the end.

  7. At the end of the agreement, type yes to agree to it and continue with the install.
  8. The JDK will now unpack and install itself. Your screen output should look similar to the following:
    Unpacking...
    Checksumming...
    Extracting...
    UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
      inflating: jdk-6u1-linux-i586.rpm  
    Preparing...                ########################################### [100%]
       1:jdk                       ########################################### [100%]
    Unpacking JAR files...
            rt.jar...
            jsse.jar...
            charsets.jar...
            tools.jar...
            localedata.jar...
            plugin.jar...
            javaws.jar...
            deploy.jar...
     
    Done.
    
  9. The install routine installs the files into the directory /usr/java/jdk1.6.0_01. It also creates two links in that directory named default and latest. It’s about time Sun has done this. I have been manually doing something like this since the JDK 1.2 days. These links make it easy to migrate to a new JVM, as you would reference the link in your shell scripts and not the actual JVM directory itself.

  10. Now we want our system to automatically put the JDK binary files into our PATH when we login for all users. To do this, edit the /etc/profile file and place the following two lines at the bottom of your file:
    JAVA_HOME=/usr/java/default; export JAVA_HOME
    PATH=$JAVA_HOME/bin:$PATH; export PATH
    
  11. Now if you logout of your system and then log back in, you should be able to run the java command to print its version. Run the following command:

    java -version
    

    And your output should look like:

    java version "1.6.0_01"
    Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
    Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
    
  12. Congratulations, your JDK is installed!



v2.0