[b]Tools/Ingredients[/b]
[b]Method/step[/b]
Uninstall OpenJDK
rpm -qa | grep java
rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64
rpm -e --nodeps tzdata-java-2012j-1.el6.noarch
JDK download official website:
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
input the command:
wget http://211.149.198.47/data/main/jdk-7u7-linux-i586.tar.gz download jdk
Enter the command: ll
You can check that the file jdk-7u7-linux-i586.tar.gz exists in the current directory, then decompress the source package in the current directory, and enter the command: tar -zxvf jdk-7u7-linux-i586.tar.gz
Enter the command: ll
You can check that the directory jdk1.7.0_07 exists in the current directory, then move it to the /usr/local/ directory, rename it to jdk7, and enter the command: mv jdk1.7.0_07 /usr/local/jdk7
Next, let's set the environment variables of jdk. The global setting method is to modify /etc/profile, which is a common environment variable for all users.
Enter the command: vi /etc/profile
Then add the following at the end of the opened file
:
JAVA_HOME=/usr/local/jdk7JRE_HOME=/usr/local/jdk7/jrePATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/libexport JAVA_HOME JRE_HOME PATH CLASSPATH
To make the environment variable take effect immediately, enter the command: source /etc/profile
Check if the installation was successful
Enter the command: java #Detect jdk bin environment ,
Then enter: javac #Detect jdk classpath environment
If successful, you will see the following java command parameter usage instructions interface;
At present, after we enter the above command, the following error may be reported:
bash: /usr/local/jdk7/bin/java: /lib/ld-linux.so.2: bad ELF interpreter:
There is no such file or directory because the 32-bit program is installed in the 64-bit system, and I am currently using the 64-bit linux version Solution: yum install glibc.i686
After I installed the above glibc.i686 and other related packages, I can execute java, javac and other commands normally. The following packages are not installed. After reinstalling, there are still the following class errors, and then continue to install the package
error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directoryyum install libstdc++.so.6
<!--[if !supportLists]-->00002. <!--[endif]-->
当然,如果你安装的是64位的jdk,就不会报该错误了。