Install JDK

  
under Linux

Install JDK under Linux as follows:

Step 1: Check if the JDK that comes with Linux is installed

(1) View the installed jdk: Br>

# rpm -qa| Grep jdk ← View jdk information or execute directly

or

# rpm -q jdk

or

# java -version

(2)rpm -qa| Grep jdk Uninstall:

(3) rpm -e rpm package name (see above) If there is a dependency, first uninstall the upper layer.

Step 2: Install JDK

<1>Download jdk-1_5_0_14-linux-i586-rpm.bin or jdk-1_5_0_14-linux-i586.bin
< from SUN p> Create a new java folder under /usr and place the installation package in the /usr/java directory

# mkdir /usr/java

<2>Install JDK

# cd /usr/java(mkdir java – this directory needs to be created)

1jdk-1_5_0_16-linux-i586-rpm.bin file installation

# chmod 777 jdk-1_5_0_16- Linux-i586-rpm.bin ← modified to executable

# ./jdk-1_5_0_16-linux-i586-rpm.bin ← select yes to agree to the above protocol

# rpm - Ivh jdk-1_5_0_16-linux-i586.rpm ← Select yes until the installation is complete

2jdk-1_5_0_16-linux-i586.bin file installation

#chmod a+x jdk-1_5_0_16-linux -i586.bin ← Make the current user have execute permission

# ./jdk-1_5_0_16-linux-i586.bin ← Select yes until the installation is complete

Step 3: Configure environment variables

<1># vi /etc/profile

<2>Add the following lines at the end:

export JAVA_HOME=/usr/java/jdk1.5.0 _16

export CLASSP ATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:$JAVA_HOME/bin

<3># source /etc/profile takes effect after execution

Step 4: Test JDK

#vi hello.java

public class hello {

public static void main(String args [ ])

{

System.out.println("Hello World!");

System.out.println("2011/1/14");

}

}

# javac hello.java

# java hello

Hello World!

2011/1/14

Seeing this means the installation was successful!

Copyright © Windows knowledge All Rights Reserved