ubuntu replace system openjdk
一些ubuntu自带jdk的。但是有时候会确实我们所要的文件。下面介绍如何replace jdk
1. 卸载现有jdk
sudo apt-get purge openjdk-\*
2. 下载jdk.
3. 创建一个目录 在/usr/local/ 文件夹下:sudo mkdir -p /usr/local/java
4. 把jdk复制到第三步的文件夹中。
sudo cp -r jdk...tar.gz /usr/local/java/
5. 解压文件
sudo tar xvzf jdk-8u51-linux-x64.tar.gz
6. 更新 /etc/profile下面的PATH.
JAVA_HOME=/usr/local/java/jdk1.8.0_51
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH
7. run 下面脚本
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.../bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.../bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.../bin/javaws" 1
8.
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_51/bin/java sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_51/bin/javac sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_51/bin/javaws
9. 重新加载下面脚本
source /etc/profile
10. roboot Ubuntu