This article shows the steps in setting up a Java environment in a Linux system.
The Java SDK version which will be installed is 1.4.2 which was downloaded from Sun Microsystems and the Linux involved is Oracle Enterprise Linux (based on the Red Hat distribution).
- Download Java SDK. The file which I downloaded was j2sdk-1_4_2_19-linux-i586-rpm.bin.
- As a root user, make the downloaded bin file executable.
# chmod 755 j2sdk-1_4_2_19-linux-i586-rpm.bin - Execute the bin file and agree to the terms and condition. Then it will extract the file to a RPM file.
# ./j2sdk-1_4_2_19-linux-i586-rpm.bin
…
Press the space bar to scroll down in “More”.
Do you agree the the above license terms? [yes or no] yes
… - Use the rpm command to install the RPM package.
# rpm –ivh j2sdk-1_4_2_19-linux-i586.rpm - The Java SDK is successfully installed. It is installed in /usr/java/j2sdk1.4.2_19.
- Setup the environment variables. Using your favorite text editor, open the user’s .bash_profile ($HOME/.bash_profile) and add in the variables below.
PATH=/usr/java/j2sdk1.4.0_03/bin:$PATH:$HOME/bin:./ export PATH export JAVA_HOME=/usr/java/j2sdk1.4.0_03 export CLASSPATH=/usr/java/j2sdk1.4.0_03/lib/tools.jar:/usr/java/j2sdk1.4.0_03/jre/lib/rt.jar:./ - Logout from your system and log back in again.
- Run the below commands to make sure the environment variables are set correctly.
$ which java /usr/java/j2sdk1.4.2_19/bin/java
$ java -version
java version “1.4.2_19″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)
Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)
Resources/references: