CentOS Use-record Contos 7 build Java Environment

Source: Internet
Author: User
Tags root access

System environment: CentOS Linux 7

Current User: Normal user

Installing jdk:jdk-10.0.1_linux-x64_bin.tar.gz

: http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html

Because CentOS 7 has built-in OPENJDK, java-version verification can be performed through the terminal.

1. View and uninstall the built-in OEPNJDK (normal user uninstall requires root access first)

Get root Permissions

Su Root

Query command:

Rpm-qa | grep JDK

Uninstall command:

RPM-E--nodeps The name that you queried above

2. Drag the JDK downloaded from the physical machine to the virtual machine (or download it directly to the virtual machine via the virtual machine's own browser)

Because it is a normal user, it can only be dragged to the directory under which the user belongs, and the other directories do not have permissions.

3. Unzip. There are two ways: one is directly extracted by the self-brought program, and one is extracted by the command line method. (The command line method is used here)

Right-click Open in Terminal (open terminal) directly in the directory

Decompression command:

TAR-ZXVF jdk-10.0. 1_linux-x64_bin.tar.gz

4. Move the extracted folder to the appropriate directory (requires root access)

5. Setting environment variables (requires root access)

To open the profile file:

Vim/etc/profile

Add the following to the end of the profile file:

Export java_home=/app/java/jdk-10.0. 1 export CLASSPATH=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/Tools.jarexport PATH= $PATH: $JAVA _home/bin

After saving, the configuration file takes effect when you execute the following command:

Source/etc/profile

If you find that the command has not yet taken effect, or if you are executing a Java command prompt in another directory, "This command cannot be found," You can restart it and look again.

6. Create a soft link (can be ignored)

If you find that you cannot execute Java and JAVAC commands under another directory, you can resolve them by creating a soft link.

Ln-s/app/java/jdk-10.0. 1/bin/java/sbin/-s/app/java/jdk-10.0. 1/bin/javac/sbin/javac

7. Verify that the configuration is successful

CentOS Use-record Contos 7 build Java Environment

Related Article

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.