ubuntu jdk 及 maven 安装
JDK安装;
1. 去Oracle官方网站:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 下载jdk对应版本,如:jdk-8u171-linux-x64.tar.gz
2. sudo tar -zxf jdk-8u171-linux-x64.tar.gz -C /usr/local,将jdk解压到/usr/local中
3.设置环境变量,在.zshrc(zsh)或/etc/profile(bash)中添加如下环境变量:
export JAVA_HOME=/usr/local/jdk1.8.0_171
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
4.更改java环境配置
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/jdk1.8.0_171/bin/java" 1 (设置JRE可用)
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/jdk1.8.0_171/bin/javac" 1 (设置JDK可用)
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/jdk1.8.0_171/bin/javaws" 1 (设置Java Web可用)
sudo update-alternatives --set java /usr/local/jdk1.8.0_171/bin/java (设置Java运行时环境)
sudo update-alternatives --set javac /usr/local/jdk1.8.0_171/bin/javac (设置Javac编译器)
sudo update-alternatives --set javaws /usr/local/jdk1.8.0_171/bin/javaws(设置Java Web运行 )
5.利用java -version 和 javac -version测试是否可用
maven安装:
1.下载apache-maven-3.3.9.bin.tar.gz
2.解压到/usr/local
sudo tar -zxf apache-maven-3.3.9-bin.tar.gz -C /usr/local
3.设置环境变量,在.zshrc(zsh)或/etc/profile(bash)中添加如下环境变量:
export M2_HOME=/usr/local/apache-maven-3.3.9
export PATH=$M2_HOME/bin:$PATH
4.使配置生效
source .zshrc或 source /etc/profile
5.验证安装是否成功
mvn -v
6.修改repository的路径(默认是用户家目录下的.m2目录,可选)
sudo vim /usr/local/apache-maven-3.3.9
/conf/settings.xml
写入
<localRepository> /path </localRepository>