Changing the Java environment under CENTOS7

Source: Internet
Author: User

1. Upload the downloaded Java package, such as http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jre-8u77-linux-x64.rpm, the directory can be defined by itself, such as/root/ elasticsearch/

2. Run the Install command:

Yum install/root/elasticsearch/jre-8u77-linux-x64.rpm

If the prompt is not successfully installed, ls–al/root/elasticsearch/jre-8u77-linux-x64.rpm see if the current file has execute permissions and if not, run

chmod +x/root/elasticsearch/jre-8u77-linux-x64.rpm, adding Execute permissions

After the installation is complete, if you are unsure whether the installation was successful, you can perform the following view commands:

Find/–maxdepth–8–name jre1.8*

Typically installed by default under/usr/java/

3. Modify the Java link

(Method 1, directly modify the symbolic link)

First look at the current Java version of Java–version, such as 1.7.0_91

Start to modify the link: Execute in turn;

Alternatives--install/usr/bin/java Java/usr/java/jre1.8.0_77/bin/java 300

Alternatives--config Java

View the Java version at this time:

Java–version, became 1.8.0_77.

(Method 2, modify the Java Path environment variable)

After installation, confirm the current installation path (not clear, according to the version you installed check execution:find/–maxdepth–8–name jre1.8*)

Add the current path to the $path variable, as the path I installed is/usr/java/jre1.8.0_77/bin

Edit the/etc/profile file using VI, vi/etc/profile/

Add at end of line:

Path=/usr/java/jre1.8.0_77/bin: $PATH;
To see if a variable has been added:
Echo $PATH
Verifying the Java version:
Java-version

Reference:

Http://www.cnblogs.com/kreo/p/4308651.html

Changing the Java environment under CENTOS7

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.