Installing and Configuring Java on RHEL 5.x

Are you a java programmer/learner? And working Java in windows platform? But do you know that it is also possible to do it in Linux platform, to do this you have to install and configure java software and it’s environment variable in Linux. So, now I am going to installing jdk 1.6 on Red Hat Enterprise Linux 5.4 you can also do it with other Distribution of Linux. So follow the steps as i have done.

Step-1: Create a folder named JDK1.6 in to root directory & keep the software into it.

[root@dbsrv ~]# mkdir /JDK1.6

Step-2: Now make sure that you have put the software into /JDK1.6 directory

[root@dbsrv ~]# cd /JDK1.6
[root@dbsrv ~]# ls –la
jdk-6u24-linux-i586-rpm.bin

Step-3: Now make the file to be executable, then unpack by executing it.

[root@dbsrv ~]# cd /JDK1.6
[root@dbsrv JDK1.6]# chmod +x jdk-6u24-linux-i586-rpm.bin
[root@dbsrv JDK1.6]# ./jdk-6u24-linux-i586-rpm.bin

Step-4: Now we need to check where the files is installed. To know this run this command

[root@dbsrv ~]# rpm –ql jdk
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/index.html
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/manifest.mf
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/nbproject
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/nbproject/file-targets.xml
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/nbproject/jdk.xml
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/nbproject/netbeans-targets.xml
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/nbproject/project.xml
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/src
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/src/ebay
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/src/ebay/server
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/src/ebay/server/Ebay.java
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/src/ebay/server/ImageProvider.java
/usr/java/jdk1.6.0_24/sample/webservices/EbayServer/src/ebay/server/Main.java
/usr/java/jdk1.6.0_24/src.zip

[root@dbsrv ~]#

Configure Java environment on Linux

After installing Java Development Kit or Java Runtime Environment on Linux, you may still need to do some configuration to get Java ready for running or compiling Java programs. The following instruction will guide you through the process of setting up JDK for software development. JRE can be configured similarly.

Step-1:Create a link of jdk.

JDK is usually installed into /usr/java directory. Create a symbolic link to the installation directory. That way makes it easier to switch between different Java versions that you may have just by redirecting the link to the appropriate target directory.

[root@dbsrv ~]# ln –s /usr/java/jdk1.6.0_24 /usr/java/j2se

Step-2: Create a java.sh file in /etc/profile.d directory with content as follows:

[root@dbsrv ~]# cd /etc/profile.d
[root@dbsrv profile.d]# vi java.sh

#!/bin/bash
JAVA_HOME=/usr/java/j2se
JAVA_FONTS=/usr/share/fonts/truetype
ANT_HOME=/usr/share/ant
PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
export PATH JAVA_HOME JAVA_FONTS ANT_HOME
export CLASSPATH=.

Step-3: Change the permission of java.sh file.

The java.sh file contains various shell commands which set and export necessary environment variables for Java. It assumes Apache Ant and Unicode TrueType fonts have been installed in appropriate directories. Ant is a tool widely used in building and executing Java applications. Shell settings from configuration files in the /etc/profile.d directory are gathered by /ect/profile during login, setting up user environment information for every user. Assign execute permissions:

[root@dbsrv profile.d]# chmod 755 java.sh

 Step-4: You can verify the availability of Java to users after login by:

[root@dbsrv ~]# java –version
java version “1.6.0_24”
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

[root@dbsrv ~]#

Note: Before execute this command you need to restart the machine, otherwise you will not get the actual result.

Author Info

Md. Kamrul Hassan

Myself is a Computer Network Specialist. Working in a training center (name - Acme IT) in Bangladesh. Basically most of the tutorial I have written here is created for my students. Happy to know if it become useful for visitors. You can find me at Facebook