[Linux]JavaEE articles: Install JDK

javaEE articles: install jdk

There are three main ways to install jdk:

1. Source code installation; manually decompress the JDK compressed package, and then set the environment variables; offline

2, yum installs JDK; warehouse installation, pay attention to the need for online installation

3. rpm install jdk; offline
installation Here mainly introduces the source code installation, the other two can refer to the link.


1. Source installation

Source code installation: Unzip the downloaded jdk compressed package, edit it in the configuration environment, and log in again.

  • Before installation, you need to upload the jdk in windos to the linux system. Here we use WinSCP software to upload files.

Here I upload the jdk to the linux system /opt.

[root@wcl opt]# ls -l /opt
-rw-r--r-- 1 root root   8924465 5月   3 14:08 jdk-7u79-linux-x64.gz
  • In the current directory: opt; Create a directory javato install jdk; Instructions used: mkdir java.

    [root@wcl opt]# mkdir java
    [root@wcl opt]# ls -l
    drwxr-xr-x 3 root root      4096 53 14:45 java
  • In the current directory: opt; extract the compressed package tojdk-7u79-linux-x64.gz ; the instructions used:/opt/javatar -zxvf jdk-7u79-linux-x64.gz -C /opt/java

    [root@wcl opt]# tar -zxvf  jdk-7u79-linux-x64.gz -C /opt/java
    jdk1.7.0_79/lib/visualvm/visualvm/update_tracking/com-sun-tools-visualvm-sa.xml
    // ... ...省略剩余解压内容

    At this point, jdk has been installed, and then we need to configure the environment variables of jdk

  • Enter the /etc/profile file to modify the global environment variables; the instructions used:vim /etc/profile

    Modifying environment variables in the /etc/profile file applies to all users; only system administrators can change this file.

    Enter the etc/profile file and configure the jdk environment variables on the last line of the file; as follows:

    [root@wcl jdk1.7.0_79]# vim /etc/profile
         // ... ...省略部分内容
    unset i
    unset -f pathmunge   //注意:这是我的文件最后一行
    
    JAVA_HOME=/opt/java/jdk1.7.0_79
    PATH=/opt/java/jdk1.7.0_79/bin:$PATH
    export JAVA_HOME PATH
    

    Note that the last three lines are my newly added code.

  • At this point, log out, log logoutin again, enter java -version, and verify whether the configuration is successful;

    [root@wcl ~]# java -version
    java version "1.7.0_79"
    Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
    Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

    Successful installation! !


The remaining installation methods refer to the link:

Three ways to install jdk in LInux Install JDK
through yum on linux

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325478035&siteId=291194637