1, download JDK installation package: jdk-7u5-linux-i586.rpm (32bit)
· Download Address: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1637583.html
· Put in/tmp directory
2. Install JDK with rpm (i.)
· [Root@c1091test ~]# cd/tmp//To/tmp directory
· [Root@c1091test tmp]# rpm-i jdk-7u5-linux-i586.rpm//install JDK
· Unpacking JAR files ...
· Rt.jar ...
· Jsse.jar ...
· Charsets.jar ...
· Tools.jar ...
· Localedata.jar ...
· Plugin.jar ...
· Javaws.jar ...
· Deploy.jar ...
· [Root@c1091test tmp]# Ls/usr/java//See if JDK is installed, you can see that it is already installed in the/usr/java directory
· Default JDK1.7.0_05 Latest
· [Root@c1091test tmp]# VI ~/.bash_profile//configure Java environment variables
3. Install JDK with RPM (II.)
· The ~/.bash_profile file is modified as follows:
· #. Bash_profile
· # get the aliases and functions
· If [f ~/.BASHRC]; Then
· . ~/.bashrc
· Fi
· # User specific environment and startup programs
· Java_home=/usr/java/jdk1.7.0_05
· Classpath=.: $JAVA _home/lib/tools.jar: $JAVA _home/lib/dt.jar
· Path= $PATH: $HOME/bin:java_home/bin: $JAVA _home/jre/bin:/sbin
· Export PATH java_home CLASSPATH
· Unset USERNAME
· Press ESC to enter: Wq save exit, if the input Java and javac can run correctly means the installation is successful. Let's do a test to see if the installation is successful
4. Test whether the JDK is installed successfully
· Navigate to/tmp directory first:
· Write a Helloworld.java file for testing
public class HelloWorld
{
public static void Main (String args[])
{
System.out.println ("helloworld!!");
}
}
[Root@localhost/]# VI Helloworld.java//write as above program
[Root@c1091test tmp]# Javac Helloworld.java
§[root@c1091test tmp]# Java HelloWorld
§helloworld!!
· If you can see the information above, the installation is successful