Linux下配置java开发环境

1、下载

JDK 8下载命令:

$ wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.tar.gz

另外其他版本下载页面:
http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u80-oth-JPR

2、解压

mkdir /opt/jdk/
tar x -C /opt/jdk -f jdk-8u66-linux-x64.tar.gz

3、安装jdk

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_66/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_66/bin/javac 100

4、系统存在多个jdk时候设置默认的jdk版本

update-alternatives --config java
update-alternatives --config javac

5、更新jdk版本使用以下命令:

# 6.2.1 Remove the existing alternatives - jdk1.8.0_66
$ sudo update-alternatives --remove java /opt/jdk/jdk1.8.0_66/bin/java
$ sudo update-alternatives --remove javac /opt/jdk/jdk1.8.0_66/bin/javac

# 6.2.2 Install new JDK alternatives - jdk1.8.0_99
$ sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_99/bin/java 100
$ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_99/bin/javac 100

# 6.2.3 Update default JDK again, select /opt/jdk/jdk1.8.0_99
$ update-alternatives --config java
$ update-alternatives --config javac

# 6.2.4 Remove the old JDK folders
$ sudo rm -rf /opt/jdk/jdk1.8.0_66/

参考:https://www.mkyong.com/java/how-to-install-oracle-jdk-8-on-debian/

标签: select, header, wget, oraclelicense, jdk, 命令, opt, mkdir, tar, java, bin, javac, jdk1.8.0

仅有一条评论

  1. vi /etc/profile

    export JAVA_HOME=/opt/jdk/jdk1.8.0_131
    export JRE_HOME=$JAVA_HOME/jre
    export CLASSPATH=.:$JAVA_HOME/lib
    export PATH=$JAVA_HOME/bin:$PATH

    source /etc/profile

添加新评论