1. check whether JDK is installed java login to the system with the root user, open a terminal input # rpm-qa | grep gcj display content contains the following information # java-1.4.2-gcj-compat-1.4.2.0-40jpp.112 # java-1.4.2-gcj-compat-devel-l.4.2.0-40jpp.112 (this package is not pre-installed) uninstall # rpm-e java-1.4.2-gcj-compat-devel-l.4.2.0-40jpp.112 # rpm-e java-1.4.2-gcj-compat-l.4.2.0-40jpp.112 if there is a dependency, don't let uninstall, just use rpm-e -- nodeps uninstall on the line to download the jdk-6u22-linux-x64-rpm.bin (ORACLE can be found on the official site) 2. add executable permissions to the file [root @ esprit java] # chmod + x j Dk-6u22-linux-x64-rpm.bin 3. run the jdk-6u22-linux-x64-rpm.bin [root @ esprit java] #. /The jdk-6u22-linux-x64-rpm.bin is generated after execution, there are other packages such as sun-javadb 4. install jdk-6u22-linux-x64-rpm [root @ esprit java] # rpm-ivh jdk-6u22-linux-x64-rpm here I jdk installed in the/usr/java directory 5. you can configure environment variables in three ways: Modify the/etc/profile file and modify the environment variables in the user directory. bashrc file, which can be directly modified in shell) Here I will only talk about modifying the/etc/profile file I used [root @ esprit java] # vi/etc/profile after opening the file Ort path user logname mail hostname histsize inputrc is added as follows: export JAVA_HOME =/usr/java/jdk1.6.0 _ 22 export PATH = $ PATH: $ JAVA_HOME/bin: $ JAVA_HOME/jre/binexport CLASSPATH =.: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib: $ CLASSPATH Press esc and enter: wq to save and exit. Make the configuration take effect soure/etc/profile6. write a simple HelloWorld in the test configuration environment to test [root @ esprit java] # vi HelloWorld. in the java file, enter: public class HelloWorld {public static void main (String args []) {System. out. println ("Hello World in Linux !! ") ;}}: Wq save and exit [root @ esprit java] # javac HelloWorld. there is no error in java. Next, [root @ esprit java] # output in java HelloWorld shell: Hello World in Linux !! In this way, the author h405589168 is completed.