Closed ggam closed 5 years ago
Interestingly, it seems that the alternatives should have been added: https://github.com/AdoptOpenJDK/openjdk-installer/blob/master/linux/rpm/config/jdk-12-hotspot/postinst.sh
I'll try to investigate a bit more.
On CentOS 7 (docker run -d -t centos:centos7
):
# yum list installed | grep adopt
adoptopenjdk-12-hotspot.x86_64 12.0.2+10-1 @AdoptOpenJDK
# which javac
/usr/bin/javac
# ls -l /usr/bin/javac
lrwxrwxrwx 1 root root 23 Sep 14 10:36 /usr/bin/javac -> /etc/alternatives/javac
# ls -l /etc/alternatives/javac
lrwxrwxrwx 1 root root 46 Sep 14 10:36 /etc/alternatives/javac -> /usr/lib/jvm/adoptopenjdk-12-hotspot/bin/javac
# javac -version
javac 12.0.2
# which jaotc
/usr/bin/jaotc
# ls -l /usr/bin/jaotc
lrwxrwxrwx 1 root root 23 Sep 14 10:36 /usr/bin/jaotc -> /etc/alternatives/jaotc
# ls -l /etc/alternatives/jaotc
lrwxrwxrwx 1 root root 46 Sep 14 10:36 /etc/alternatives/jaotc -> /usr/lib/jvm/adoptopenjdk-12-hotspot/bin/jaotc
# jaotc --version
jaotc 12.0.2+10
People usually get in trouble if they install multiple versions of Java. Not all vendors stick to the same convention when defining the priority of the alternatives (what update-alternatives
should consider as a "better", i.e. newer, version). This can lead to mismatches (e.g. java
points to Azul Zulu and javac
to AdoptOpenJDK). There's nothing we can do about that. It's the user's responsibility to select the desired versions with update-alternatives
and to do it for both java
and javac
. To list the available alternatives:
# update-alternatives --list
libnssckbi.so.x86_64 auto /usr/lib64/pkcs11/p11-kit-trust.so
ld auto /usr/bin/ld.bfd
java auto /usr/lib/jvm/adoptopenjdk-12-hotspot/bin/java
javac auto /usr/lib/jvm/adoptopenjdk-12-hotspot/bin/javac
To use e.g. AdoptOpenJDK 12 with HotSpot:
# update-alternatives --set javac /usr/lib/jvm/adoptopenjdk-12-hotspot/bin/javac
# update-alternatives --set java /usr/lib/jvm/adoptopenjdk-12-hotspot/bin/java
If your problems persist, please tell us the OS you're using, what Java versions you have installed and which steps you took to get there.
Thanks for the response. Perhaps I'm doing something wrong.
My OS is Fedora 30. I have the following JDKs installed:
[guillermo@localhost linux]$ alternatives --display java | grep priority
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64/jre/bin/java - family java-1.8.0-openjdk.x86_64 priority 1800222
/usr/lib/jvm/java-12-openjdk-12.0.2.9-1.rolling.fc30.x86_64/bin/java - family java-latest-openjdk.x86_64 priority 1
/usr/lib/jvm/java-11-openjdk-11.0.4.11-0.fc30.x86_64/bin/java - family java-11-openjdk.x86_64 priority 1
/usr/lib/jvm/adoptopenjdk-12-openj9/bin/java - priority 1121
/home/guillermo/sapmachine-jdk-12.0.2/ - priority 10
/usr/lib/jvm/adoptopenjdk-12-hotspot/bin/java - priority 1121
/usr/lib/jvm/adoptopenjdk-11-hotspot/bin/java - priority 1111
And this is the list of alternatives:
[guillermo@localhost linux]$ update-alternatives --list | grep j
javadocdir auto /usr/share/javadoc/java-12-openjdk-12.0.2.9-1.rolling.fc30.x86_64/api
java manual /usr/lib/jvm/adoptopenjdk-12-hotspot/bin/java
jre_11_openjdk auto /usr/lib/jvm/jre-11-openjdk-11.0.4.11-0.fc30.x86_64
jre_1.8.0 auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64/jre
whois auto /usr/bin/jwhois
jre_11 auto /usr/lib/jvm/java-11-openjdk-11.0.4.11-0.fc30.x86_64
javac auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64/bin/javac
jre_12 auto /usr/lib/jvm/java-12-openjdk-12.0.2.9-1.rolling.fc30.x86_64
jre_1.8.0_openjdk auto /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64
java_sdk_1.8.0_openjdk auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64
java_sdk_1.8.0 auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64
jre_openjdk auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64/jre
java_sdk_openjdk auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64
jre_12_openjdk auto /usr/lib/jvm/jre-12-openjdk-12.0.2.9-1.rolling.fc30.x86_64
javadoc
for example is not listed as an alternative, and the one from the system is used:
[guillermo@localhost linux]$ alternatives --display javadoc
[guillermo@localhost linux]$ ls -l /etc/alternatives/javadoc
lrwxrwxrwx. 1 root root 71 sep 7 12:40 /etc/alternatives/javadoc -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64/bin/javadoc
Other commands not contained on JDK 8 just don't work as they are not provided by any installation:
lrwxrwxrwx. 1 root root 71 sep 7 12:40 /etc/alternatives/javadoc -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64/bin/javadoc
[guillermo@localhost linux]$ jlink
bash: jlink: no se encontró la orden...
Una orden similar es: 'link'
What I expected (and from the code it seems it was the idea) was all tools be registered as alternatives.
The problem seems to be this line here from the list of alternatives:
javac auto /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64/bin/javac
By using the javac alternative from java-1.8.0-openjdk-1.8.0.222.b10-0.fc30.x86_64
you're effectively telling Fedora to use the developer tools from that package. As a result, you don't get those from adoptopenjdk-12-hotspot
. You have to run update-alternatives --set javac /usr/lib/jvm/adoptopenjdk-12-hotspot/bin/javac
, too, to get those.
Thanks, that worked perfectly. I basically use alternatives only to change between java
implementations and have little more knowledge about how it works. I thought javac
referred only to the javac command and not to the whole set of development tools.
From what you say, this is standard behavior, but I think some lines might be added to the insallation instructions on the website, clarifying the alternatives
that are installed and how to change them.
Thanks again!
I install AdoptOpenJDK from the RPM repository as described on https://adoptopenjdk.net/installation.html#linux-pkg
It seems to only add
java
andjavac
toalternatives
, but there are a lot of binaries on the bin folder:This leads to surprising "conflicts" with the Java version bundled with the operation system, as I have an AdoptOpenJDK 12
java
and an upstream OpenJDK 8javadoc
:). . Is it possible to add them toalternatives
?