- 下载Oracle JDK的tar.gz
- sudo mkdir -p /usr/local/java
- sudo cp -r jdk.*.tar.gz /usr/local/java
- sudo tar xvzf jdk-8u45-linux-x64.tar.gz
- 修改PATH(/etc/profile)
sudo nano /etc/profile
and paste the following at the end of the file:
JAVA_HOME=/usr/local/java/jdk1.8.0_45
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH
-
向系统声明新Oracle JDK可用:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_45/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_45/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws.itweb" "javaws.itweb" "/usr/local/java/jdk1.8.0_45/bin/javaws.itweb" 1
-
更改Oracle JDK为默认JDK:
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_45/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_45/bin/javac
sudo update-alternatives --set javaws.itweb /usr/local/java/jdk1.8.0_45/bin/javaws.itweb
-
使修改的/etc/profile生效:
source /etc/profile
-
重启
网友评论