Installing the JDK on a RedHat Linux System

Today, i feel i should share a solution to another very important process that causes some hitches especially for coders and developers that are to a certain extent upcoming.

It is about the simple java installation on linux redhat.

Ordinarily on a newly installed Redhat Linux server, you might not get a java installation that you desire or even none at all. If you are in such a position then i am happy you got to this blog.

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. You can contact me if you are having a challenge doing that.
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!

 

Regards.

Advertisements

One thought on “Installation of the JDK on a RedHat Linux System

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s