1.首先從官網(wǎng)下載jdk
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2.創(chuàng)建jdk目標(biāo)路徑
sudo mkdir /usr/lib/jvm
3.進(jìn)入到下載jdk的目錄 解壓縮
sudo tar -C /usr/lib/jvm -xzf jdk-7u55-linux-x64.tar.gz
4.查看本機(jī)上是否還有java可選棘伴。這里用到以下命令
sudo update-alternatives --list java
如果出現(xiàn)錯(cuò)誤
5.配置環(huán)境變量命令:
sudo gedit ~/.bashrc
添加以下代碼:
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_55
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
6.查看是否配置成功:
java -version