linux JDK 安装详解

1、检查一下系统中的jdk版本

[root@node50 ~]#java -version

#java -version

#java -version

openjdk version “1.8.0_131”
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)

2、检测jdk安装包

[root@node50 ~]

#rpm -qa | grep java

tzdata-java-2017b-1.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.131-11.b12.el7.x86_64
python-javapackages-3.4.1-11.el7.noarch

3、卸载openjdk

[root@node50 ~]#yum remove openjdk

4、安装新的jdk

首先到jdk官网上下载你想要的jdk版本

https://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

我这提供本次实验版本

链接: https://pan.baidu.com/s/1IwOGxfwsi5ww91w5ELZEBQ 提取码: rbr7

5.解压 jdk-8u131-linux-x64.tar.gz安装包

[root@node50 ~]# tar -xf jdk-8u191-linux-x64.tar.gz -C /usr/local/

查看

[root@node50 ~]

# ls /usr/local/jdk1.8.0_191/
bin jre README.html THIRDPARTYLICENSEREADME.txt
COPYRIGHT lib release
include LICENSE src.zip
javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txt

maven安装

1、下载maven

wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz

2、解压至/usr/local目录

tar -xf apache-maven-3.2.5-bin.tar.gz -C /usr/local/

6.设置环境变量在末尾添加4行

[root@node50 ~]

# vim /etc/profile

export JAVA_HOME=/usr/local/jdk1.8.0_191
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

export MAVEN_HOME=/usr/local/apache-maven-3.2.5
export PATH=${PATH}:${MAVEN_HOME}/bin

6、执行profile文件

[root@node50 ~]

# source /etc/profile
这样可以使配置不用重启即可立即生效。

7、检查新安装的jdk

[root@node50 ~]

# java -version
java version “1.8.0_191”
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

8.验证mvn

[ ~]# mvn -v
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T01:29:23+08:00)
Maven home: /usr/local/apache-maven-3.2.5
Java version: 1.8.0_191, vendor: Oracle Corporation
Java home: /usr/local/jdk1.8.0_191/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: “linux”, version: “3.10.0-957.el7.x86_64”, arch: “amd64”, family: “unix”

原文链接:,转发请注明来源!

发表评论