Default Java on Mint Linux

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 00:20, 26 October 2019 by Admin (Talk | contribs)

Jump to: navigation, search

or how to configure the default Java on Linux Mint when more than one version is installed. I am fairly certain that this applies to most of the Debian derivatives such as those considered spin-offs of Ubuntu.

Also, below explains how to get rid of ugly IBM Java old crappy version also known as IBM Java Runtime Environment.

Ubuntu / Mint needs some kind of Java for software like LibreOffice to function. In the absence of Oracle or OpenJDK it will, without asking you, install ibm-java80-jre which is compatible with very little today. Get rid of it...

sudo apt remove ibm-java80-jre

The Ubuntu / Mint insists on having either OpenJDK or IBM Java on the system. Even if you install Oracle Java (real Java) you will still have one of the others unless you really go in and start ripping things out manually, which can be a bad thing.

Got lots of Java binaries floating around? Java bin here and there, multiple versions, finding out that OpenJDK version 11 hates Minecraft or other games?

You can have more than one version on the system. You can configure your software to pick a specific version. However, the system references a default Java binary in the absence of a specific path and sometimes dependencies of the Java application will, even when launched specifically from the command line, refer to the default configured system.

 /usr/bin/java -jar somesoftware.jar

YOU CAN USE A SYSTEM COMMAND TO SET THE DEFAULT JAVA PREFERENCE

update-alternatives --config java

You will see something like this:

here are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
* 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

The minecraft launcher is not popular with OpenJDK 11 however works well with OpenJDK 8.

Now that we changed our default, lets run the java command without absolute path to the java

# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

Looks good! It is no longer reporting version 11.

What the update-alternatives script does is maintains symbolic links to various executable binaries in directories like /usr/bin because those are the ones executed by default from the environment path. The command isn't just for picking a Java version.

Some Related Pages