Difference between revisions of "Default Java on Mint Linux"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
m (There is only one alternative in link group java)
Line 38: Line 38:
 
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.
 
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.
  
== There is only one alternative in link group java ==
+
== Error: There is only one alternative in link group java ==
  
 
#    Download the version you wish to run, for our example Oracle 8 from the file jre-8u181-linux-x64.tar.gz
 
#    Download the version you wish to run, for our example Oracle 8 from the file jre-8u181-linux-x64.tar.gz

Revision as of 17:33, 2 February 2020

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.

Error: There is only one alternative in link group java

  1. Download the version you wish to run, for our example Oracle 8 from the file jre-8u181-linux-x64.tar.gz
  2. Extract jre-8u181-linux-x64.tar.gz to /usr/local - you end up the the java binary in the path: /usr/local/jre1.8.0_181/bin
  3. Add the java to the update-alternatives link group - sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/jre1.8.0_181/bin/java" 8
  4. Then run update-alternatives

Some Related Pages