Java development environment to build centos

First, prepare the environment

centos7

Second, the system clean-up


First, we need the operating system checks to see if the default JDK is already installed, you can execute the following command to view the system comes with the JDK,

rpm -qa | grep jdk
if installed centos7 system installed by default openjdk for example, and we need to uninstall. If not, skip this step.

Uninstall command:

yum remove xxx #xxx to query for the results of a command

Third, download and install the JDK

We went to Java's official website (https://www.oracle.com/technetwork/java/javase/downloads/index.html) download JDK, select the version you can download their own needs. I chose JDK8, the downloaded version is jdk-8u141-linux-x64.rpm. Note that you need to be logged in to download the official website to download an Oracle JDK.

download

We can use the following two methods to download the JDK to centos system:

1) Method a:

① we can choose the download on the windows, and then uploaded to the centos system. We can upload tool by lrzsz, if not installed, install it by following commands:

lrzsz install yum
② then execute the following command on centos system:

rz
③ find the downloaded file in the pop upload, as shown below:

 

2) Method II:

① direct download via wget tools on centos. Use wget to download a variety of problems occur newer version of jdk8, is currently looking for a variety of information also have not been able to bypass the normal check Oracle's official website direct free download a newer version of JDK by wget. However, using the following link to download jdk-8u141-linux-x64.rpm is currently normal.
      wget --no-cookies --no-check- certificate --header "Cookie: gpw_e24 = http% 3A% 2F% 2Fwww.oracle.com% 2F; oraclelicense = accept-securebackup-cookie" "http: // download. oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm "

PS: Currently recommended to use the first method, you can choose your own version of JDK required for download; the second is temporarily not found a solution to the freedom to choose the version, but also want to have a small partner can tell about, discuss what> _ < .

  installation

Centos system to download the JDK later, we went to install

Execute the following command to install rpm -ivh jdk-8u141-linux-x64.rpm

 

After mounting the above-described commands, the default installation path of / usr / java

For example the path I install JDK is: /usr/java/jdk1.8.0_141

 

Fourth, configure the environment variables

① First, enter the following command centos command line window to configure the environment variables:

      vim /etc/profile

② increase in the bottom of the open file:

export JAVA_HOME=/usr/java/jdk1.8.0_141

export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$JAVA_HOME/bin:/usr/local/php/bin
export PATH

 

Note: JAVA_HOME to the JDK installation path, using the default installation path here

③ add $ JAVA_HOME / bin in the PATH variable. Note that, in this document, an environment variable between a plurality of values ​​by which the text input in the colon ":" to be separated:

PATH = $ PATH: $ JAVA_HOME / bin

as shown below:

After ④ After configuring the environment variables, press the ESC key to exit vim upper left corner of the keyboard editing mode, and by the vim: to save and exit "wq" command.

⑤ In order to make the environment variables take effect immediately, we also need to enter the following command:

      source  /etc/profile


Fifth, check

Java -version execute the command line window, you can see the revision number, as shown below normal installation configuration means that successful:

           

Guess you like

Origin www.cnblogs.com/kai0438/p/12114360.html