I'm having a great deal of trouble installing Java 8 onto Kubuntu 18.04 rather than the default Java 11, and would appreciate any help, as the advice from the usual web sites is not helping.
In my particular case, I'm trying to install Java version 8 to run Minecraft, as it does not seem to run on the more current Java 11 (at least for Linux) [as noted here at JDK Crash when attempting to run Minecraft on Ubuntu 18.04 and here at [Minecraft won't launch in Ubuntu 18.04 ]
Try as I might to sudo apt-get remove openjdk-11-jre
or sudo apt-get purge openjdk-11-jdk
and other similar commands, every time I type java -version
it tells me that it's version 11 rather than version 8.
Finally, I followed the advice on how to completely uninstall Java, from How to completely uninstall Java?
$ dpkg-query -W -f='${binary:Package}\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common' | xargs sudo apt-get -y remove
$ sudo apt-get -y autoremove
$ sudo bash -c 'ls -d /home/*/.java' | xargs sudo rm -rf
$ sudo rm -rf /usr/lib/jvm/*
$ for g in ControlPanel java java_vm javaws jcontrol jexec keytool mozilla-javaplugin.so orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200 appletviewer apt extcheck HtmlConverter idlj jar jarsigner javac javadoc javah javap jconsole jdb jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd native2ascii rmic schemagen serialver wsgen wsimport xjc xulrunner-1.9-javaplugin.so; do sudo update-alternatives --remove-all $g; done
$ sudo updatedb
$ sudo locate -b '\pack200'
Finally, no more Java! And now to reinstall only Java 8 and not Java 11, so I did
$ sudo apt-get install openjdk-8-jdk
$ sudo apt-get install openjdk-8-jre
(I think the second command was redundant.)
And now I do not have any java command. Typing "java -version"[Enter] results in an error that there is no such command. However, "javac" is a valid command, so apparently I have a Java compiler installed but not a Java whatever-you-call-the-not-compiler (the "run-time environment"?) Running programs Java-based programs like Minecraft or the mtgForge results in the program self-terminating after a few seconds.
I tried:
$ update-java-alternatives --list
java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64`
Not sure why version 11 is still there. I couldn't seem to use update-java-alternatives --set
to make version 8 the default (or ANY default at all). When I tried
update-java-alternatives --set 1081
update-java-alternatives: directory does not exist: /usr/lib/jvm/1081
So then I checked what was available under
$ ls /usr/lib/jvm/
.java-1.11.0-openjdk-amd64.jinfo .java-1.8.0-openjdk-amd64.jinfo java-8-openjdk-amd64/
So I tried:
$ update-java-alternatives --set java-8-openjdk-amd64
update-java-alternatives: file does not exist: /usr/lib/jvm/.java-8-openjdk-amd64.jinfo
That's because the filename is different from the directory name. Filename is .java-1.8.0-openjdk-amd64.jinfo
On the other hand, using the confusingly similar command
$ update-alternatives --config java
update-alternatives: error: no alternatives for java
But if I say
$ update-alternatives --config javac
There is only one alternative in link group javac (providing /usr/bin/javac): /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
Nothing to configure.
This is where I am stuck. How do I get it so I can run the java
command? I already have the javac
command. Which package do I need to install to get the java
command? As noted above, I've already installed openjdk-8-jdk
and openjdk-8-jre
.