CentOS-7 system, installation of Java and configuration of environment variables

Source: Internet
Author: User

1. Check if Java is installed (mostly two Openjava)
Java-version

2. Uninstall the Openjava, you need to uninstall two, the package name after the replacement of a good
RPM-E--nodeps java-1.xx.0-openjdk-xxx

3. Download the RPM package from Oracle official website, you can also download the tar package, but the personal feeling RPM package unloading and installation are fast, there is a need to leave a message;
Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

4. Use XFTP5, put in the virtual machine, can also be downloaded in other ways (such as: wget) or transmission, transmission is recommended to use the root account, because it may cause the problem of permissions, here I am my own virtual machine, storage location can be arbitrary;

5. Unzip the installation RPM package
RPM-IVH jdk-8u171-linux-x64.rpm

6. Find the default path for the system to install automatically, the main purpose is to configure environment variables
Find/-name ' java.* '
This means to find files that meet the ' java.* ' criteria in the root directory;
Enter the file directory,
Pwd
Copy the file directory

7. Configure the environment variables; Here you only need to change a bit, the path behind the java_home and replace it with your own Java installation path, java_home mainly refers to the Java file Bin directory in front of the path;
Vim/etc/profile
Insert at the end, as follows:
Export JAVA_HOME=/USR/JAVA/JDK1.8.0_171-AMD64
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH
Save exit
: Wq
Execution configuration takes effect
Source/etc/profile

8. Check again, or you can come to a HelloWorld
Java-version
Java
Javac

9. Questions, notes save updated environment variables, the above command basically no impact, can be compiled, can be executed; do not know what the reason;

CentOS-7 system, installation of Java and configuration of 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.