วันอาทิตย์ที่ 18 กันยายน พ.ศ. 2559

Install Oracle Java 9 (JDK9) in Ubuntu, Linux Mint or Debian via PPA

To add the WebUpd8 Oracle Java PPA and install Oracle Java 9 in all supported Ubuntu / Linux Mint versions, use the following commands:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java9-installer

To install Oracle Java 9 in Debian, you can setup "add-apt-repository" as we've explained a while back and use the Ubuntu installation instructions above. You can also manually add the repository and key and install Oracle Java 9 in Debian using the following commands:
su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java9-installer
exit

Tip: if you're behind a firewall / router that blocks some of the redirects required to download the Oracle Java archive, you can download the JDK tar.gz archive manually and place it under /var/cache/oracle-jdk9-installer - then, installing the "oracle-java9-installer" package will use the local archive instead of trying it to download it itself.

After installing the package, you can check the Java version by running "java -version" in a terminal, which should display an output similar to this:
andrei@andrei-desktop:~$ java -version
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 9-ea+126)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+126, mixed mode)
Or, "javac -version":
andrei@andrei-desktop:~$ javac -version
javac 1.9.0-ea
And so on.


Automated installation (auto accept license)


The Oracle Java 9 Installer prompts you to accept the Oracle license before proceeding with the installation and it's only required once, so you don't have to accept the license with each update. If you want to automate the installation process, you can use the command below to automatically accept the Oracle Java 9 license:
echo oracle-java9-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections


Setting Java environment variables


To automatically set up the Java 9 environment variables, you can install the following package:
sudo apt-get install oracle-java9-set-default
If you've already installed oracle-java7-set-default or oracle-java8-set-default, they will be automatically removed when installing oracle-java9-set-default (and the environment variables will be set for Oracle Java 9 instead).

ไม่มีความคิดเห็น:

แสดงความคิดเห็น