ubuntu下配置jdk第一步與win10下相同 首先來到官網下載jdk:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htmlhtml
在這裏下載了java
壓縮包的版本。linux
1.下載完成後,解壓文件 使用命令:ubuntu
tar -zxvf jdk-8u191-linux-x64.tar.gz
2.解壓完成後 將文件移動到 /usr/libbash
mv jdk1.8.0_191 /usr/lib/jdk1.8
3.修改環境變量oracle
(1)使用全局設置方法,它是全部用戶的共用的環境變量spa
sudo gedit ~/.bashrc
(2)在文件末尾追加路徑3d
export JAVA_HOME=/usr/local/jdk1.8 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=.:${JAVA_HOME}/bin:$PATH
:wq保存code
3.生效~/.bashrc文件htm
source ~./bashrc
4.最後執行這幾條命令
sudo update-alternatives --install /usr/bin/java java /usr/lib/jdk1.8/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jdk1.8/bin/javac 300 sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jdk1.8/bin/jar 300 sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jdk1.8/bin/javah 300 sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jdk1.8/bin/javap 300
就成功能夠 java javac java -version啦