Java 在 Linux 中的安装与配置

Java 下载及环境变量设置

下载

wget https://repo.huaweicloud.com/java/jdk/8u181-b13/jdk-8u181-linux-x64.tar.gz

环境变量设置

1# java
2export  JAVA_HOME=/root/jdk1.8.0_181
3export  PATH=$PATH:$JAVA_HOME/bin
4export  CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Maven 下载及环境变量设置

下载

wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz

环境变量设置:

1# maven
2export M2_HOME=/root/apache-maven-3.6.1
3export PATH=$PATH:$M2_HOME/bin

maven 配置

 1vi $M2_HOME/conf/settings.xml
 2
 3设置本地仓库位置:
 4    <localRepository>/app/dev/maven-repository</localRepository>
 5设置国内镜像:
 6    <mirror>
 7      <id>aliyun</id>
 8      <name>aliyun</name>
 9      <url>https://maven.aliyun.com/repository/public</url>
10      <mirrorOf>central</mirrorOf>
11    </mirror>
12设置默认的jdk:
13    <profile>
14      <id>jdk-1.8</id>
15
16      <activation>
17        <jdk>1.8</jdk>
18        <activeByDefault>true</activeByDefault>
19      </activation>
20
21      <properties>
22        <maven.compiler.source>1.8</maven.compiler.source>
23        <maven.compiler.target>1.8</maven.compiler.target>
24        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
25      </properties>
26    </profile>