Linux安装Java/Maven
所需文件:jdk 下载
安装Java
INSTALL_PATH=/opt/soft TAR_FILE=/mnt/d/resources/soft/jdk-8u152-linux-x64.tar.gz # 安装 mkdir -p $INSTALL_PATH tar -xzf $TAR_FILE -C $INSTALL_PATH JDK_FOLDER=`tar -tvf $JDK_FILE |head -1 |awk -F' ' {'print $6'}` ln -s $INSTALL_PATH/$JDK_FOLDER $INSTALL_PATH/java # 修改系统环境变量 echo -e '\n\n#Java' >> /etc/profile echo 'export JAVA_HOME='$INSTALL_PATH'/java' >> /etc/profile echo 'export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH' >> /etc/profile echo 'export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib' >> /etc/profile # 测试 source /etc/profile java -version
Maven
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz INSTALL_PATH=/opt/soft TAR_FILE=`pwd`/apache-maven-3.6.1-bin.tar.gz # 安装 mkdir -p $INSTALL_PATH tar -xzf $TAR_FILE -C $INSTALL_PATH MAVEN_FOLDER=`tar -tvzf $TAR_FILE |head -1 |awk -F' ' {'print $6'} |awk -F'/' {'print $1'}` ln -s $INSTALL_PATH/$MAVEN_FOLDER $INSTALL_PATH/maven # 修改系统环境变量 echo -e '\n\n#Maven' >> /etc/profile echo 'export MAVEN_HOME='$INSTALL_PATH'/maven' >> /etc/profile echo 'export PATH=$MAVEN_HOME/bin:$PATH' >> /etc/profile # 测试 source /etc/profile mvn -version