Comment installer Oracle JDK 8 sur Debian
Dans ce tutoriel, nous allons vous montrer comment installer Oracle JDK 8 sur Debian, manuellement.
Environnement:
-
Debian 7
-
OpenJDK 1.7 est installé. (Passez à Oracle JDK 8 plus tard)
Au moment de la rédaction de cet article, OpenJDK 1.8 n'est pas encore inclus dans le référentiel apt-get par défaut. Je n'aime tout simplement pas le calendrier de dépôt apt par défaut, il vient constamment avec des versions plus anciennes ou obsolètes.
Note
Ce guide est testé dans d'autres dérivés Debian comme Ubuntu 14 et Mint 1.7.2.
1. Vérification rapide
1.1 A quick Java version check :
$ java -version java version "1.7.0_75" OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~deb7u1) OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode) $ javac -version javac 1.7.0_75
Un OpenJDK 1.7 existant est installé, pas de problème, nous allons vous montrer comment le basculer vers JDK 8.
1.2 A quick search via apt-cache
, there is no openjdk-8… yet.
$ apt-cache search openjdk ... openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT openjdk-7-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless) openjdk-6-jre - OpenJDK Java runtime, using Hotspot JIT openjdk-6-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless) ...
2. Obtenez Oracle JDK 8
1.1 Visit Oracle JDK download page
1.2 Find a Linux x64 version, in this example, we will get the jdk-8u66-linux-x64.tar.gz
via wget
command.
$ pwd /home/example $ wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.tar.gz
Si vous ne souhaitez pas utiliserwget
(pourquoi?), Téléchargez simplement le fichier et importez-le manuellement sur votre serveur.
3. Extraits de / opt / jdk /
3.1 Extracts it to path /opt/jdk/jdk1.8.0_66
$ pwd /home/example $ sudo mkdir /opt/jdk/ $ sudo mv ~/jdk-8u66-linux-x64.tar.gz /opt/jdk/ $ sudo cd /opt/jdk/ $ pwd /opt/jdk/ $ sudo tar -zxf jdk-8u66-linux-x64.tar.gz $ ls -ls total 177056 4 drwxr-xr-x 3 root root 4096 Oct 27 13:05 . 4 drwxr-xr-x 3 root root 4096 Oct 27 13:03 .. 4 drwxr-xr-x 8 uucp 143 4096 Oct 7 00:40 jdk1.8.0_66 177044 -rw-r--r-- 1 root root 181287376 Oct 8 15:56 jdk-8u66-linux-x64.tar.gz
Note
Vous pouvez également essayer cette commande d'extraction d'une ligne.
$ sudo tar x -C /opt/jdk -f jdk-8u66-linux-x64.tar.gz
4. Installer JDK
4.1 Make /opt/jdk/jdk1.8.0_66
as a new JDK alternatives for both /usr/bin/java
and /usr/bin/javac
$ sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_66/bin/java 100 $ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_66/bin/javac 100
4.2 Update the default JDK, for both java
and javac
$ update-alternatives --config java There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 auto mode * 1 /opt/jdk/jdk1.8.0_66/bin/java 100 manual mode 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode Press enter to keep the current choice[*], or type selection number: 1 update-alternatives: using /opt/jdk/jdk1.8.0_66/bin/java to provide /usr/bin/java (java) in manual mode
$ update-alternatives --config javac There are 2 choices for the alternative javac (providing /usr/bin/javac). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1051 auto mode * 1 /opt/jdk/jdk1.8.0_66/bin/javac 100 manual mode 2 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1051 manual mode Press enter to keep the current choice[*], or type selection number: 1 update-alternatives: using /opt/jdk/jdk1.8.0_66/bin/javac to provide /usr/bin/javac (javac) in manual mode
5. Vérification
Vérifiez à nouveau la version de Java.
$ java -version java version "1.8.0_66" Java(TM) SE Runtime Environment (build 1.8.0_66-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode) root@hydra:/opt/jdk# $ javac -version javac 1.8.0_66
Terminé. Profitez de votre Lambda!
6. Extras… Comment mettre à jour?
Supposons que le nouveaujdk1.8.0_99
soit publié et que nous souhaitons le mettre à jour.
6.1 Download the JDK tar files and extracts it to /opt/jdk/jdk1.8.0_99
6.2 Self-explanatory.
# 6.2.1 Remove the existing alternatives - jdk1.8.0_66 $ sudo update-alternatives --remove java /opt/jdk/jdk1.8.0_66/bin/java $ sudo update-alternatives --remove javac /opt/jdk/jdk1.8.0_66/bin/javac # 6.2.2 Install new JDK alternatives - jdk1.8.0_99 $ sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_99/bin/java 100 $ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_99/bin/javac 100 # 6.2.3 Update default JDK again, select /opt/jdk/jdk1.8.0_99 $ update-alternatives --config java $ update-alternatives --config javac # 6.2.4 Remove the old JDK folders $ sudo rm -rf /opt/jdk/jdk1.8.0_66/
Que diriez-vous de la mise à niveau vers le prochain Oracle JDK 9? vous savez ce qu'il faut faire :)