1. 程式人生 > >ubuntu jdk安裝

ubuntu jdk安裝

oracl target .com classpath nbsp jdk1.8 www. ava 編譯

1. 去Oracle官方網站:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 下載jdk對應版本,如:jdk-8u171-linux-x64.tar.gz

2. sudo tar -zxf jdk-8u171-linux-x64.tar.gz /usr/local,將jdk解壓到/usr/local中

3.設置環境變量,在.zshrc(zsh)或/etc/profile(bash)中添加如下環境變量:

  export JAVA_HOME=/usr/local/jdk1.8.0_171
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH

4.更改java環境配置

  sudo update-alternatives --install "/usr/bin/java" "java" "/home/goodong/Desktop/jdk1.8.0_102/bin/java" 1 (設置JRE可用)
  sudo update-alternatives --install "/usr/bin/javac" "javac" "/home/goodong/Desktop/jdk1.8.0_102/bin/javac" 1 (設置JDK可用)

  sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/home/goodong/Desktop/jdk1.8.0_102/bin/javaws" 1 (設置Java Web可用

  sudo update-alternatives --set java /home/goodong/Desktop/jdk1.8.0_102/bin/java (設置Java運行時環境

  sudo update-alternatives --set javac /home/goodong/Desktop/jdk1.8.0_102/bin/javac (設置Javac編譯器

  sudo update-alternatives --set javaws /home/goodong/Desktop/jdk1.8.0_102/bin/javaws(設置Java Web運行

5.利用java -version 和 javac -version測試是否可用

ubuntu jdk安裝