Install jdk on centos and set Environment Variables

Source: Internet
Author: User

Install jdk on centos and set Environment Variables
JDK installation of CentOS

  • Download JDK 1.8

  • At this time (20170324) the latest version:jdk-8u72-linux-x64.tar.gz

  • Official Website: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  • OpenJDK is installed in CentOS by default. We recommend that you uninstall it first.

  • Check the JDK command:Java-version

  • Query the local JDK installation program;rpm -qa|grep java

    • The result is as follows:
    java-1.6.0-openjdk-1.6.0.38-1.13.10.0.el6_7.x86_64java-1.7.0-openjdk-1.7.0.95-2.6.4.0.el6_7.x86_64tzdata-java-2015g-2.el6.noarch
    • Unmount the preceding three files (--nodepsPurpose: Ignore the dependency check ):
    • sudo rpm -e --nodeps java-1.6.0-openjdk-1.6.0.38-1.13.10.0.el6_7.x86_64
    • sudo rpm -e --nodeps java-1.7.0-openjdk-1.7.0.95-2.6.4.0.el6_7.x86_64
    • sudo rpm -e --nodeps tzdata-java-2015g-2.el6.noarch
    • You can also uninstall it together:sudo rpm -e --nodeps java-1.6.0-openjdk-1.6.0.38-1.13.10.0.el6_7.x86_64 java-1.7.0-openjdk-1.7.0.95-2.6.4.0.el6_7.x86_64 tzdata-java-2015g-2.el6.noarch
    • For CentOS 7:sudo rpm -e --nodeps javapackages-tools-3.4.1-11.el7.noarch java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64 java-1.7.0-openjdk-headless-1.7.0.131-2.6.9.0.el7_3.x86_64 python-javapackages-3.4.1-11.el7.noarch java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el7_3.x86_64 java-1.8.0-openjdk-headless-1.8.0.121-0.b13.el7_3.x86_64 tzdata-java-2017a-1.el7.noarch
  • Install JDK 1.8

    • We installjdk-8u72-linux-x64.tar.gzExample
    • My personal habits/optCreate a directory under the DirectorysetupsUsed to store various software installation packages;/usrCreateprogramUsed to store various decompressed software packages. The following sections are based on this habit.
    • I personally have used the third-party source:EPEL、RepoForgeIf you appearyum install XXXXXIf the installation fails, it is likely that you have no relevant source. Please refer to my article on source settings.
    • Unzip the installation package:sudo tar -zxvf jdk-8u72-linux-x64.tar.gz
    • Move the package to the installation directory that I am used:mv jdk1.8.0_72/ /usr/program/
    • Configure environment variables:
      • Edit the configuration file:Sudo vim/etc/profile or sudo vim/etc/profile. d/java. sh (recommended for Management)
      • Add the following content to the tail of the file:
      # JDKJAVA_HOME=/usr/program/jdk1.8.0_72JRE_HOME=$JAVA_HOME/jrePATH=$PATH:$JAVA_HOME/binCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOMEexport JRE_HOMEexport PATHexport CLASSPATH
      • Run the following command to refresh the Configuration ):Source/etc/profile or. java. sh
      • Check whether the latest JDK is used:java -version

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.