Centos6.2 uninstall the system and install Sun JDK with openjdk

Source: Internet
Author: User

1. Uninstall openjdk
View the current system's JDK: rpm-Qa | grep JDK (I found here: java-1.6.0-openjdk-1.6.0.0-1.43.1.10.6.el6_2.i686), if not found, you can use rpm-Qa | grep gcj

Remove the built-in JDK: Yum-y remove java-1.6.0-openjdk-1.6.0.0-1.43.1.10.6.el6_2.i686 ,:

2. Install Sun JDK
Since I downloaded jdk-7-linux-i586.tar.gz, You can unzip it directly in the installation directory,
Go to/USR and run the tar-zxvf jdk-7-linux-i586.tar.gz. After decompression, you can see that a folder named jdk1.7.0 is added under the/usr directory.
3. Configure the environment
VI/etc/profile open the profile file and add it at the end of the profile file

JAVA_HOME=/usr/jdk1.7.0PATH=$JAVA_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOMEexport PATHexport CLASSPATH

Save and close the profile file, and run the source/etc/profile command to make the modification take effect (you can restart the system without executing this command)
In this way, JDK is successfully installed.
Test whether the installation is successful: run Java-version. The following result shows that the installation is successful.

[root@localhost ~]# java -versionjava version "1.7.0"Java(TM) SE Runtime Environment (build 1.7.0-b147)Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)

If-Bash: [root command not found error please open the/etc/profile file and find something similar to the following (the following information is added when I installed the Oracle database, and the error lies in this one):

if [$USER = 'oracle']; then        if [$SHELL = '/bin/ksh']; then                ulimit -p 16384                ulimit -n 65536        else                ulimit -u 16384 -n 65536        fifi

Modify the preceding content:

if [ $USER = 'oracle' ]; then        if [ $SHELL = '/bin/ksh' ]; then                ulimit -p 16384                ulimit -n 65536        else                ulimit -u 16384 -n 65536        fifi

Error Cause Analysis: in fact, [and $ user need to be separated by spaces. When they are connected together, they become a variable such as [root, which is escaped. Therefore, after spaces are added, source/etc/profile is normal.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.