Install JDK under Linux and configure environment variables

Source: Internet
Author: User

Check JDK version, uninstall OPENJDK version (the difference between JDK and OPENJDK does not repeat here)

Check the java–version, javac–version command to see the version first (i)

Checked for JDK version 1.7.0.45; re-enter Rpm-qa|grep Java view (ii)

Note: There may be a difference in the version of OPENJDK installed for different CentOS versions; If no list is displayed, you can see the 4th step directly

Uninstall the above three files (requires root permission, login root permission uninstall) (iii)

RPM-E--nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

RPM-E--nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

RPM-E--nodeps Tzdata-java-2013g-1.el6.noarch

View JDK information again (iv)

You are now ready to install the Oracle version of the JDK.

Unzip the JDK, unzip the command: Tar-xvzf jdk-7u25-linux-x64.tar.gz

JDK Location:/home/codebrother/jdk/jdk-7u25-linux-x64.tar.gz, unzip the current path, after decompression, the JDK folder will appear, enter the JDK directory, and see the contents of the directory (v)

Configuring the JDK environment variables

In a Linux system, you need to add the bin directory of the JDK in path, create a classpath, and add the JDK's lib directory.

JDK's home directory:/home/codebrother/jdk/jdk1.7.0_25

The bin directory of the JDK:/home/codebrother/jdk/jdk1.7.0_25/bin

Lib directory for JDK:/home/codebrother/jdk/jdk1.7.0_25/lib

Edit ~/.BASHRC File

Command:

VI ~/.BASHRC

Add the following variable (vi)

Export Java_home=/home/codebrother/jdk/jdk1.7.0_25export java_bin= $JAVA _home/binexport java_lib= $JAVA _home/ Libexport classpath=.: $JAVA _lib/tools.jar: $JAVA _lib/dt.jarexport path= $JAVA _bin: $PATH

Press the ESC key, and then: Wq Save to exit

Make the JDK environment variable effective, source ~/.BASHRC (vii)

View JDK version

Input java-version, javac–version (eight)

Install JDK under Linux and configure environment variables

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.