1

I have been trying to install openjdk 9 on Debian 9 and get everything to point to that install. However, something is off and does not want to update where the default java command in the terminal points to.

I installed openjdk9 with a simple sudo apt-get install openjdk-9-jre openjdk-9-jdk

If I run readlink $(which java) it points to /etc/alternatives/java

If I run readklink /etc/alternatives/java it points to /usr/lib/jvm/java-9-openjdk-amd64/bin/java

But the weirdest thing is that if I run it all at once with readlink -f $(which java) it points to /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java Which is exactly what I get when I run java -version in the terminal:

openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-1-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

The default-java symlink also points to openjdk 8.

However, javac -version in the terminal looks right: javac 9.0.1

update-alternatives looks right for both java and javac:

$ sudo 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-9-openjdk-amd64/bin/java       1091      auto mode
  1    /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode
* 2   /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      manual mode



$ sudo 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-9-openjdk-amd64/bin/javac   1091      auto mode
  1       /usr/lib/jvm/java-8-openjdk-amd64/bin/javac   1069      manual mode
* 2       /usr/lib/jvm/java-9-openjdk-amd64/bin/javac   1091      manual mode

Does anyone have any idea why I can't get the java command to be in agreement with the rest of the system? Or have ideas about what else to try next?

Thanks much.

EDIT Adding transcript

    resu@laptop/usr/lib/jvm
$ ls -l
total 12
lrwxrwxrwx 1 root root   24 Jan  6  2017 default-java -> java-1.8.0-openjdk-amd64
drwxr-xr-x 4 root root 4096 Dec 16 16:47 java-1.5.0-gcj-6-amd64
lrwxrwxrwx 1 root root   20 Oct 25  2016 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64
lrwxrwxrwx 1 root root   20 Oct 26 19:44 java-1.9.0-openjdk-amd64 -> java-9-openjdk-amd64
drwxr-xr-x 7 root root 4096 Nov 26 01:18 java-8-openjdk-amd64
drwxr-xr-x 9 root root 4096 Dec 10 20:26 java-9-openjdk-amd64
lrwxrwxrwx 1 root root   34 Dec 31 20:09 java-latest -> /usr/lib/jvm/java-9-openjdk-amd64/

resu@laptop/usr/lib/jvm
$ cd /etc/alternatives/

resu@laptop/etc/alternatives
$ ls -l | grep java
lrwxrwxrwx 1 root root  50 Dec 31 20:06 appletviewer -> /usr/lib/jvm/java-9-openjdk-amd64/bin/appletviewer
lrwxrwxrwx 1 root root  60 Dec 31 20:06 appletviewer.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/appletviewer.1.gz
lrwxrwxrwx 1 root root  46 Jan 21  2017 extcheck -> /usr/lib/jvm/java-8-openjdk-amd64/bin/extcheck
lrwxrwxrwx 1 root root  56 Jan 21  2017 extcheck.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/extcheck.1.gz
lrwxrwxrwx 1 root root  42 Dec 10 20:26 idlj -> /usr/lib/jvm/java-9-openjdk-amd64/bin/idlj
lrwxrwxrwx 1 root root  52 Dec 10 20:26 idlj.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/idlj.1.gz
lrwxrwxrwx 1 root root  56 Oct  8 17:17 itweb-settings -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/itweb-settings
lrwxrwxrwx 1 root root  66 Oct  8 17:17 itweb-settings.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/itweb-settings.1.gz
lrwxrwxrwx 1 root root  43 Dec 10 20:26 jaotc -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jaotc
lrwxrwxrwx 1 root root  41 Dec 10 20:26 jar -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jar
lrwxrwxrwx 1 root root  51 Dec 10 20:26 jar.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jar.1.gz
lrwxrwxrwx 1 root root  47 Dec 10 20:26 jarsigner -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jarsigner
lrwxrwxrwx 1 root root  57 Dec 10 20:26 jarsigner.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jarsigner.1.gz
lrwxrwxrwx 1 root root  42 Dec 31 20:06 java -> /usr/lib/jvm/java-9-openjdk-amd64/bin/java
lrwxrwxrwx 1 root root  52 Dec 31 20:06 java.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/java.1.gz
lrwxrwxrwx 1 root root  43 Dec 31 20:06 javac -> /usr/lib/jvm/java-9-openjdk-amd64/bin/javac
lrwxrwxrwx 1 root root  53 Dec 31 20:06 javac.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/javac.1.gz
lrwxrwxrwx 1 root root  45 Dec 10 20:26 javadoc -> /usr/lib/jvm/java-9-openjdk-amd64/bin/javadoc
lrwxrwxrwx 1 root root  55 Dec 10 20:26 javadoc.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/javadoc.1.gz
lrwxrwxrwx 1 root root  43 Dec 10 20:26 javah -> /usr/lib/jvm/java-9-openjdk-amd64/bin/javah
lrwxrwxrwx 1 root root  53 Dec 10 20:26 javah.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/javah.1.gz
lrwxrwxrwx 1 root root  43 Dec 10 20:26 javap -> /usr/lib/jvm/java-9-openjdk-amd64/bin/javap
lrwxrwxrwx 1 root root  53 Dec 10 20:26 javap.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/javap.1.gz
lrwxrwxrwx 1 root root  48 Oct  8 17:17 javaws -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/javaws
lrwxrwxrwx 1 root root  58 Oct  8 17:17 javaws.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/javaws.1.gz
lrwxrwxrwx 1 root root  42 Dec 10 20:26 jcmd -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jcmd
lrwxrwxrwx 1 root root  52 Dec 10 20:26 jcmd.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jcmd.1.gz
lrwxrwxrwx 1 root root  46 Dec 31 20:06 jconsole -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jconsole
lrwxrwxrwx 1 root root  56 Dec 31 20:06 jconsole.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jconsole.1.gz
lrwxrwxrwx 1 root root  41 Dec 10 20:26 jdb -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jdb
lrwxrwxrwx 1 root root  51 Dec 10 20:26 jdb.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jdb.1.gz
lrwxrwxrwx 1 root root  47 Dec 10 20:26 jdeprscan -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jdeprscan
lrwxrwxrwx 1 root root  43 Dec 10 20:26 jdeps -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jdeps
lrwxrwxrwx 1 root root  53 Dec 10 20:26 jdeps.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jdeps.1.gz
lrwxrwxrwx 1 root root  43 Dec 31 20:06 jexec -> /usr/lib/jvm/java-9-openjdk-amd64/lib/jexec
lrwxrwxrwx 1 root root  48 Dec 31 20:06 jexec-binfmt -> /usr/lib/jvm/java-9-openjdk-amd64/lib/jar.binfmt
lrwxrwxrwx 1 root root  42 Jan 21  2017 jhat -> /usr/lib/jvm/java-8-openjdk-amd64/bin/jhat
lrwxrwxrwx 1 root root  52 Jan 21  2017 jhat.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/jhat.1.gz
lrwxrwxrwx 1 root root  43 Dec 10 20:26 jhsdb -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jhsdb
lrwxrwxrwx 1 root root  44 Dec 10 20:26 jimage -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jimage
lrwxrwxrwx 1 root root  43 Dec 10 20:26 jinfo -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jinfo
lrwxrwxrwx 1 root root  53 Dec 10 20:26 jinfo.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jinfo.1.gz
lrwxrwxrwx 1 root root  41 Dec 31 20:06 jjs -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jjs
lrwxrwxrwx 1 root root  51 Dec 31 20:06 jjs.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jjs.1.gz
lrwxrwxrwx 1 root root  43 Dec 10 20:26 jlink -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jlink
lrwxrwxrwx 1 root root  42 Dec 10 20:26 jmap -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jmap
lrwxrwxrwx 1 root root  52 Dec 10 20:26 jmap.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jmap.1.gz
lrwxrwxrwx 1 root root  42 Dec 10 20:26 jmod -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jmod
lrwxrwxrwx 1 root root  41 Dec 10 20:26 jps -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jps
lrwxrwxrwx 1 root root  51 Dec 10 20:26 jps.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jps.1.gz
lrwxrwxrwx 1 root root  48 Dec 10 20:26 jrunscript -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jrunscript
lrwxrwxrwx 1 root root  58 Dec 10 20:26 jrunscript.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jrunscript.1.gz
lrwxrwxrwx 1 root root  47 Jan 21  2017 jsadebugd -> /usr/lib/jvm/java-8-openjdk-amd64/bin/jsadebugd
lrwxrwxrwx 1 root root  57 Jan 21  2017 jsadebugd.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/jsadebugd.1.gz
lrwxrwxrwx 1 root root  44 Dec 10 20:26 jshell -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jshell
lrwxrwxrwx 1 root root  44 Dec 10 20:26 jstack -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jstack
lrwxrwxrwx 1 root root  54 Dec 10 20:26 jstack.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jstack.1.gz
lrwxrwxrwx 1 root root  43 Dec 10 20:26 jstat -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jstat
lrwxrwxrwx 1 root root  53 Dec 10 20:26 jstat.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jstat.1.gz
lrwxrwxrwx 1 root root  44 Dec 10 20:26 jstatd -> /usr/lib/jvm/java-9-openjdk-amd64/bin/jstatd
lrwxrwxrwx 1 root root  54 Dec 10 20:26 jstatd.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/jstatd.1.gz
lrwxrwxrwx 1 root root  45 Dec 31 20:06 keytool -> /usr/lib/jvm/java-9-openjdk-amd64/bin/keytool
lrwxrwxrwx 1 root root  55 Dec 31 20:06 keytool.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/keytool.1.gz
lrwxrwxrwx 1 root root  64 Oct  8 17:18 mozilla-javaplugin.so -> /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so
lrwxrwxrwx 1 root root  50 Jan 21  2017 native2ascii -> /usr/lib/jvm/java-8-openjdk-amd64/bin/native2ascii
lrwxrwxrwx 1 root root  60 Jan 21  2017 native2ascii.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/man/man1/native2ascii.1.gz
lrwxrwxrwx 1 root root  42 Dec 31 20:06 orbd -> /usr/lib/jvm/java-9-openjdk-amd64/bin/orbd
lrwxrwxrwx 1 root root  52 Dec 31 20:06 orbd.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/orbd.1.gz
lrwxrwxrwx 1 root root  45 Dec 31 20:06 pack200 -> /usr/lib/jvm/java-9-openjdk-amd64/bin/pack200
lrwxrwxrwx 1 root root  55 Dec 31 20:06 pack200.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/pack200.1.gz
lrwxrwxrwx 1 root root  54 Oct  8 17:17 policyeditor -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/policyeditor
lrwxrwxrwx 1 root root  64 Oct  8 17:17 policyeditor.1.gz -> /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/policyeditor.1.gz
lrwxrwxrwx 1 root root  48 Dec 31 20:06 policytool -> /usr/lib/jvm/java-9-openjdk-amd64/bin/policytool
lrwxrwxrwx 1 root root  58 Dec 31 20:06 policytool.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/policytool.1.gz
lrwxrwxrwx 1 root root  42 Dec 10 20:26 rmic -> /usr/lib/jvm/java-9-openjdk-amd64/bin/rmic
lrwxrwxrwx 1 root root  52 Dec 10 20:26 rmic.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/rmic.1.gz
lrwxrwxrwx 1 root root  42 Dec 31 20:06 rmid -> /usr/lib/jvm/java-9-openjdk-amd64/bin/rmid
lrwxrwxrwx 1 root root  52 Dec 31 20:06 rmid.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/rmid.1.gz
lrwxrwxrwx 1 root root  49 Dec 31 20:06 rmiregistry -> /usr/lib/jvm/java-9-openjdk-amd64/bin/rmiregistry
lrwxrwxrwx 1 root root  59 Dec 31 20:06 rmiregistry.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/rmiregistry.1.gz
lrwxrwxrwx 1 root root  47 Dec 10 20:26 schemagen -> /usr/lib/jvm/java-9-openjdk-amd64/bin/schemagen
lrwxrwxrwx 1 root root  57 Dec 10 20:26 schemagen.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/schemagen.1.gz
lrwxrwxrwx 1 root root  47 Dec 10 20:26 serialver -> /usr/lib/jvm/java-9-openjdk-amd64/bin/serialver
lrwxrwxrwx 1 root root  57 Dec 10 20:26 serialver.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/serialver.1.gz
lrwxrwxrwx 1 root root  48 Dec 31 20:06 servertool -> /usr/lib/jvm/java-9-openjdk-amd64/bin/servertool
lrwxrwxrwx 1 root root  58 Dec 31 20:06 servertool.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/servertool.1.gz
lrwxrwxrwx 1 root root  47 Dec 31 20:06 tnameserv -> /usr/lib/jvm/java-9-openjdk-amd64/bin/tnameserv
lrwxrwxrwx 1 root root  57 Dec 31 20:06 tnameserv.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/tnameserv.1.gz
lrwxrwxrwx 1 root root  47 Dec 31 20:06 unpack200 -> /usr/lib/jvm/java-9-openjdk-amd64/bin/unpack200
lrwxrwxrwx 1 root root  57 Dec 31 20:06 unpack200.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/unpack200.1.gz
lrwxrwxrwx 1 root root  43 Dec 10 20:26 wsgen -> /usr/lib/jvm/java-9-openjdk-amd64/bin/wsgen
lrwxrwxrwx 1 root root  53 Dec 10 20:26 wsgen.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/wsgen.1.gz
lrwxrwxrwx 1 root root  46 Dec 10 20:26 wsimport -> /usr/lib/jvm/java-9-openjdk-amd64/bin/wsimport
lrwxrwxrwx 1 root root  56 Dec 10 20:26 wsimport.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/wsimport.1.gz
lrwxrwxrwx 1 root root  41 Dec 10 20:26 xjc -> /usr/lib/jvm/java-9-openjdk-amd64/bin/xjc
lrwxrwxrwx 1 root root  51 Dec 10 20:26 xjc.1.gz -> /usr/lib/jvm/java-9-openjdk-amd64/man/man1/xjc.1.gz

resu@laptop/etc/alternatives
$ which java
/usr/bin/java

resu@laptop/etc/alternatives
$ type java
java is hashed (/usr/bin/java)

resu@laptop/etc/alternatives
$ readlink $(which java)
/etc/alternatives/java

resu@laptop/etc/alternatives
$ readlink -f $(which java)
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

resu@laptop/etc/alternatives
$ java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-1-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

resu@laptop/etc/alternatives
$ javac -version
javac 9.0.1

resu@laptop/etc/alternatives
$ sudo 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-9-openjdk-amd64/bin/java       1091      auto mode
  1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1069      manual mode
* 2            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      manual mode

Press <enter> to keep the current choice[*], or type selection number: ^C

resu@laptop/etc/alternatives
$ sudo 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-9-openjdk-amd64/bin/javac   1091      auto mode
  1            /usr/lib/jvm/java-8-openjdk-amd64/bin/javac   1069      manual mode
* 2            /usr/lib/jvm/java-9-openjdk-amd64/bin/javac   1091      manual mode
  • readlink & readlink -f may not give identical answers. It would be informative to edit in a complete transcript of the session where you run all these commands, and also ls -l of the various locations and type java. – Michael Homer Jan 1 '18 at 3:25
  • @MichaelHomer I have added the content in, please let me know if anything else is needed. – resu Jan 1 '18 at 15:53
  • If you’re still having problems, update-java-alternatives may help. It should already be on your system. – Guy Jan 7 '18 at 13:17
  • @Guy I ran sudo update-java-alternatives -s java-1.9.0-openjdk-amd64 and got update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-9-openjdk-amd64/lib/IcedTeaPlugin.so. Seems like I need the IcedTea plugin? I looked around but could not find that plugin for java 9, any ideas what should be done? – resu Jan 11 '18 at 1:15
  • 1
    I think it’s been discontinued from java 9. stackoverflow.com/questions/2701100/… sounds like it’s similar to your problem? – Guy Jan 12 '18 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.