Linux 安装Java环境
# Linux 安装Java环境
# 一、安装Java(手动)
# 1、前往Oracle官网下载源码包
Java SE 8u231官网目录:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
# 2、创建Java目录
在linux环境中创建Java目录,/usr/local/java
,将java安装包上传至此目录中
# 3、配置环境变量
1)编辑/etc/profile
文件
vim /etc/profile
## 在末尾添加
export JAVA_HOME=/usr/local/java/jdk1.8.0_231
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
1
2
3
4
5
6
7
2
3
4
5
6
7
2)重载环境变量
source /etc/profile
1
3)添加软链接
ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java
1
# 4、检查Java版本
java -version
1
# 二、安装Maven(手动)
# 1、前往Maven官网下载源码包
Maven 3.2.6下载地址:http://mirror.cc.columbia.edu/pub/software/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.tar.gz
# 2、创建maven目录
在linux环境中创建maven目录,/usr/local/maven
,将maven安装包上传至此目录中
# 3、配置环境变量
1)编辑/etc/profile
文件
vim /etc/profile
## 将下面这两行代码拷贝到文件末尾并保存
export MAVEN_HOME=/usr/local/maven/apache-maven-3.6.2
export PATH=${MAVEN_HOME}/bin:${PATH}
1
2
3
4
5
6
2
3
4
5
6
2)重载环境变量
source /etc/profile
1
# 4、查看结果
mvn –v
1
# 5、替换Maven源(阿里云)
①编辑
vim /usr/local/maven/apache-maven-3.6.2/conf/settings.xml
1
②更改mirror配置
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
1
2
3
4
5
6
2
3
4
5
6
# 6、指定下载资源位置
<localRepository>/usr/local/maven/repository</localRepository>
1
# 7、指定JDK版本
<profile>
<id>jdk1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# 附:本环境下Maven最简配置
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/usr/local/maven/repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<id>jdk1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profiles>
</settings>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
参考资料
上次更新: 2020/06/11, 15:06:00
- 01
- Activiti使用手册(4)- Bpmn2规范06-11
- 02
- linux手动RPM安装gcc,g++06-11