1

This question already has an answer here:

Background of the question is that I have tried (in vain) to set up my newly installed box with Java 9 together with Eclipse Oxygen.

Those won't work together (there are multiple questions about this, and it looks like every problem is a special case with a different cause).

The direct reason seams to be that Eclipse (eclipse.ini) cannot start the JVM, and the popup with the parameters is not even accessible to copy & paste.

So I did a sudo apt-get remove openjdk-9-jdk-headless, but after that java -version still told me it's 1.9.

Next try was sudo apt-get remove openjdk-9-jre-headless. Now the shell can't find any Java at all. Fine, so far, as I deliberately removed it.

Now I tried to install JRE 8 with sudo apt-get install openjdk-8-jre-headless (and I really wonder if that headless is kind of an omen).

I get

Reading package lists... Done
Building dependency tree       
Reading state information... Done
openjdk-8-jre-headless is already the newest version (8u151-b12-0ubuntu0.16.04.2).
openjdk-8-jre-headless set to manually installed.
The following packages were automatically installed and are no longer required:
  ant ant-optional aspectj default-jdk default-jdk-headless
  eclipse-platform-data eclipse-rcp fastjar gconf2 jarwrapper junit junit4
  libapache-pom-java libart-2.0-2 libasm3-java libasm4-java libaspectj-java
  libbonobo2-0 libbonobo2-common libbonoboui2-0 libbonoboui2-common
  libcanberra0 libcglib3-java libcommons-beanutils-java libcommons-cli-java
  libcommons-codec-java libcommons-collections3-java libcommons-compress-java
  libcommons-dbcp-java libcommons-digester-java libcommons-httpclient-java
  libcommons-logging-java libcommons-parent-java libcommons-pool-java
  libdb-java libdb-je-java libdb5.3-java libdb5.3-java-jni libeasymock-java
  libecj-java libequinox-osgi-java libfelix-bundlerepository-java
  libfelix-gogo-command-java libfelix-gogo-runtime-java
  libfelix-gogo-shell-java libfelix-osgi-obr-java libfelix-shell-java
  libfelix-utils-java libgail18 libgeronimo-jpa-2.0-spec-java
  libgeronimo-osgi-support-java libglade2-0 libgnome-2-0
  libgnome-keyring-common libgnome-keyring0 libgnome2-0 libgnome2-bin
  libgnome2-common libgnomecanvas2-0 libgnomecanvas2-common libgnomeui-0
  libgnomeui-common libgnomevfs2-0 libgnomevfs2-common libhamcrest-java
  libice-dev libicu4j-49-java libicu4j-java libjetty8-java libjline-java
  libjsch-java libjtidy-java libkxml2-java liblucene2-java libobjenesis-java
  liborbit-2-0 libosgi-annotation-java libosgi-compendium-java
  libosgi-core-java libosgi-foundation-ee-java libpthread-stubs0-dev
  libregexp-java libservlet3.0-java libservlet3.1-java libsm-dev
  libswt-cairo-gtk-3-jni libswt-glx-gtk-3-jni libswt-gnome-gtk-3-jni
  libswt-gtk-3-java libswt-gtk-3-jni libswt-webkit-gtk-3-jni libtdb1
  libtomcat7-java libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev
  libxt-dev openjdk-8-jdk sat4j sound-theme-freedesktop x11proto-core-dev
  x11proto-input-dev x11proto-kb-dev xorg-sgml-doctools xtrans-dev
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

OK, I can read and write, so I did that proposed autoremove and repeated the install command, but still have no Java:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
openjdk-8-jre-headless is already the newest version (8u151-b12-0ubuntu0.16.04.2).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

What is happening, and how can I fix it?

marked as duplicate by karel, Fabby, Eric Carvalho, George Udosen, Elder Geek Jan 12 '18 at 0:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Your output isn't easy to read (interpret the errors). It appears you clicked on the quote markup rather than the code markup. The code markup will preserve the formatting which is easier for to interpret. Consider re-running your commands and editing your question and replacing the current quoted text with coded markup. If you advise me when it's done, it would be a breeze for me to glance at it and identify what's going wrong. – L. D. James Jan 11 '18 at 0:25
  • @L.D.James right you are, I didn't notice. – Gyro Gearloose Jan 11 '18 at 0:41
  • For most java-dependent applications, I will set their java path explicitly in the application's configuration files. Often this is through the JAVA_HOME environment variable -- or something similar -- to the package I get from Oracle. This gets around some of the issues that arise when using a global java path, and also gives flexibility where one application wants version x and another wants version y I'm sure there are excellent reasons against this approach but I haven't encountered any in the fifteen+ years I've been using java. – Stephen Boston Jan 11 '18 at 2:22
10

You didn't have to uninstall Java 9 to change versions. Run this to specify the java version to be used by default:

$ sudo update-alternatives --config java
  • Thank you, but doesn't work: update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives update-alternatives: warning: /etc/alternatives/java is dangling; it will be updated with best choice There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-9-openjdk-amd64/bin/java Nothing to configure. – Gyro Gearloose Jan 11 '18 at 0:58
  • The new error you're seeing may be related to incomplete installations (resulting from your previous attempt to remove version 9). I suggest that you satisfy the update-alternatives app to have a choice by reinstalling version 9. Run sudo apt install openjdk-9-jdk openjdk-8-jdk. Then use the update-alternatives app. – L. D. James Jan 11 '18 at 1:06
  • It quite looks like I have messed up my system: Errors were encountered while processing: /var/cache/apt/archives/openjdk-9-jdk_9~b114-0ubuntu1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) – Gyro Gearloose Jan 11 '18 at 1:10
  • It looks like ubuntu lost track of installed packages. I have quite a talent for doing havoc on software ;-) . – Gyro Gearloose Jan 11 '18 at 1:14
  • Run this: sudo dpkg -i --force-overwrite /var/cache/apt/archives/openjdk-9-jdk_9~b114-0ubuntu1_amd64.deb – L. D. James Jan 11 '18 at 1:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.