palto42 but not fully clear why a default Java version causes issues. What's the problem with the approach distributions like Ubuntu take where I can select a default version?
For starters, Ubuntu use an antiquated system of symlink redirection that is a part of dpkg
itself. Packages have to be known to provide these alternative commands and this all has to be heavily integrated into dpkg
, apt
, and graphical package management tools. I have personally used this system for years on Ubuntu and it's fine, until it breaks, and then it's awful to fix. That's before you assess this solution ideologically and realize that this whole process goes against the stateless approach to packaging that we strive for in Solus.
Is the symlik to a default version breaking anything else?
It actually can break things pretty easily. Let's say you have two Java programs that are started via shell script. Both scripts are hard-coded to use /usr/bin/java
. The first program requires JDK 8 and the second program requires JDK 11. Now you try to get both of them working. First you install JDK 8. update-alternatives
is run and sets it as the default java. The first program will now run fine, but the second program will not. So you install JDK 11 and update-alternatives
is run and asks you if you want to switch the default to JDK 11. You say yes. Now the second program runs, but the first program fails. It's at this point you realize that before running each program you will have to make sure you have set the correct version of Java. You also realize that anyone else using the computer will need to have sudo privileges to modify the symlinks because /usr/bin
is protected. One of the simplest possible use-cases and it already falls apart.
Now, let's try this another way. Each script is modified to look for JAVA_HOME/bin/java
. When you create the .desktop entries for the applications, you run the program with Exec=env JAVA_HOME=path/to/jdk /usr/bin/script
. Now, both the JDK 8 and JDK 11 programs can use the correct JDK. No configuration was necessary. No symlinks were created or modified. Everything just works.