DevHeads.net

Fedora, Packaging, Java, and Shrooms

Hi,

I'm thinking of switching to Fedora 30 Silverblue(once it comes out of beta
anyway) from Arch linux. One of the requirements is to be able to install,
compile from source and easily switch between JDK builds. However, Fedora
fails to meet these requirements so badly I'm fairly certain whoever
packaged and approved the various Java RPMs was on shrooms(partial offense,
sorry but this is nuts).

Confused? Never installed Java in Fedora before? Lets go down the rabbit
hole together!

Firstly, the java version installed by doing:

rpm-ostree install java

gets you Java 8. I understand that Red Hat is providing support until
sometime 2023 however I feel it to be much more appropriate that this
either gives the latest LTS(11 currently) or the newest JDK(12 currently).
Even if still technically support, installing a JRE that old isn't likey to
be advised. Even in Ubuntu 18.10 you get Java 11.

OK, so just specify the specific versions that you actually need and
everything will work as it should. No big deal, right? Nope.

alternatives(see: <a href="https://fedoraproject.org/wiki/Java" title="https://fedoraproject.org/wiki/Java">https://fedoraproject.org/wiki/Java</a>), which is supposed
to allow you to switch between Java versions, flat out doesn't work. You
tell it to list all alternatives like so:

alternatives --display java

and the command executes without printing anything. Odd. Let's just check
what's in /usr/lib/jvm for a sanity check:

ls /usr/lib/jvm

java-11-openjdk-11.0.2.7-7.fc30.x86_64
java-12-openjdk-12.0.0.33-1.ea.1.rolling.fc30.x86_64
java-1.8.0-openjdk-1.8.0.201.b09-6.fc30.x86_64
jre
jre-11
jre-11-openjdk
jre-11-openjdk-11.0.2.7-7.fc30.x86_64
jre-12
jre-12-openjdk
jre-12-openjdk-12.0.0.33-1.ea.1.rolling.fc30.x86_64
jre-1.8.0
jre-1.8.0-openjdk
jre-1.8.0-openjdk-1.8.0.201.b09-6.fc30.x86_64
jre-openjdk

...

What. I only installed Java 8, Java 11, and Java 12. Installing Java on
either Ubuntu and Arch doesn't duplicate any JRE/JDK like this.

OK, so lets open it in nautilus:

nautilus /usr/lib/jvm

Those aren't duplicates, all but 3 folders are system links? What? This
should be the one and only system location for JRE/JDK(s). What's going on
here? Where do they go?

They go to /etc/alternatives. I guess this is supposed to be how
alternatives finds alternative JRE/JDK installs. Ubuntu doesn't have to do
this for update-alternatives nor does Arch's archlinux-java script but...
OK. This is insanely complicated for no real good reason.

But wait, we aren't done yet because what's being linked to from
/usr/lib/jvm isn't a file, it's... another system link. Back to the 3 non
system links in /usr/lib/jvm which have horrendously long and complex
folder names. Is calling them
java-<version>-<jre/jdk>-<oracle/zulu/openjdk> not enough?

To top this "what" fest off, the JRE/JDK folders in /etc/alternatives
aren't even named properly. That is to say, "jre" is attached to the
front even if what's being linked is a JDK. Yes, a JDK contains a JRE but
it's still horribly confusing for no good reason. Like, imagining if
alternatives did work, does it list duplicate entries for each JRE/JDK? For
example:

jre_11
java-11-openjdk

which(again) system link to the same JDK install.

What shroom induced insanity is this? Why does alternatives not work?