Getting Started with Java - install JDK in the Linux environment and configuration environment variable

Getting Started with Java - install JDK in the Linux environment and configuration environment variable

Abstract: This paper instructions to install the JDK in a Linux environment, as well as configure the environment variables after the installation is complete.

installation

Use compressed package downloaded for installation

In the official website to download Java version required:

https://www.oracle.com/technetwork/java/javase/downloads/index.html

Because it is installed on a Linux environment, so you want to download  .tar.gz  extension files can be decompressed in the Linux system.

Note that the downloaded archive to match the number of bits Linux system, you can  CAT / proc / Version  Display system version command.

Use a good tool to download files to upload to a PC with Linux systems.

The archive's contents to  / opt  directory:

1 [root@localhost opt]# tar -zxvf jdk-8u91-linux-x64.tar.gz 

Wait for the extraction is complete, so far, Java on Linux installation is complete.

Use yum command to install

Use  yum Search the JDK  command to view the available installation packages:

 1 [root@localhost opt]# yum search jdk
 2 已加载插件:fastestmirror
 3 Loading mirror speeds from cached hostfile
 4  * base: mirrors.tuna.tsinghua.edu.cn
 5  * extras: mirrors.tuna.tsinghua.edu.cn
 6  * updates: mirrors.tuna.tsinghua.edu.cn
 7 ============================================================ N/S matched: jdk =============================================================
 8 ...
 9 java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
10 java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
11 java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
12 java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
13 java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment 8
14 java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment 8
15 java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle 8
16java- 1.8 . 0 -openjdk-src.x86_64: the OpenJDK Source Bundle 8 
17  ...
 18  
19    name and description Search only, use the "search all" try.
20 [root @ localhost opt] #

Select the installation package installation:

1 [root@localhost opt]# yum install -y java-1.8.0-openjdk.x86_64

Wait for the program to complete the installation.

Configuration environment variable

Use vim editor to open the  / etc  directory  profile  file, enter the following and save:

1 #set java environment
2 JAVA_HOME=/opt/jdk1.8.0_91
3 PATH=$PATH:$JAVA_HOME/bin
4 CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
5 export JAVA_HOME PATH CLASSPATH

Refresh configuration using the command:

1 [root@localhost ~]# source /etc/profile
2 [root@localhost ~]# 

View Java version:

1 [root@localhost ~]# java -version
2 java version "1.8.0_91"
3 Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
4 Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
5 [root@localhost ~]# 

It represents the environment variable configuration successful.

Guess you like

Origin www.cnblogs.com/shamao/p/11955117.html