Replies: 2 comments
-
That's correct. The Please see the Usage section of the README file in the package repository for information on running the OpenJDK Snap package or configuring it for your development environment. Note that the README provides two ways to use the OpenJDK snap:
For the first option, you can set up your environment by sourcing the $ java --version
openjdk 17.0.8.1 2023-08-24
OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 17.0.8.1+1-Ubuntu-0ubuntu122.04, mixed mode, sharing)
$ . $(openjdk)
$ java --version
openjdk 21.0.1 2023-10-17
OpenJDK Runtime Environment (build 21.0.1+12-snap)
OpenJDK 64-Bit Server VM (build 21.0.1+12-snap, mixed mode, sharing) If you're running Ubuntu 18.04 or later, you can use the second option by defining the $ java --version
openjdk 17.0.8.1 2023-08-24
OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 17.0.8.1+1-Ubuntu-0ubuntu122.04, mixed mode, sharing)
$ export JAVA_HOME=/snap/openjdk/current/jdk
$ export PATH=$JAVA_HOME/bin:$PATH
$ java --version
openjdk 21.0.1 2023-10-17
OpenJDK Runtime Environment (build 21.0.1+12-snap)
OpenJDK 64-Bit Server VM (build 21.0.1+12-snap, mixed mode, sharing) These steps are documented in the README file, which is linked from the OpenJDK Snap package description in the Snap Store. |
Beta Was this translation helpful? Give feedback.
-
Actually, it turns out you can add the JDK tools in the OpenJDK Snap package to your system alternatives! It's a tedious process, though, if you're doing it manually for all of the tools in the JDK: $ ls /snap/openjdk/current/jdk/bin
jar javap jdeps jlink jrunscript jwebserver
jarsigner jcmd jfr jmap jshell keytool
java jconsole jhsdb jmod jstack rmiregistry
javac jdb jimage jpackage jstat serialver
javadoc jdeprscan jinfo jps jstatd You would need to run a command like the following for each of the tools: $ sudo update-alternatives \
--install /usr/bin/java java /snap/openjdk/current/jdk/bin/java 2101 \
--slave /usr/share/man/man1/java.1 java.1 /snap/openjdk/current/jdk/man/man1/java.1 You don't need the $ update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /snap/openjdk/current/jdk/bin/java 2101 auto mode
1 /snap/openjdk/current/jdk/bin/java 2101 manual mode
2 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
3 /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1711 manual mode
Press <enter> to keep the current choice[*], or type selection number:
$ update-alternatives --display java
java - auto mode
link best version is /snap/openjdk/current/jdk/bin/java
link currently points to /snap/openjdk/current/jdk/bin/java
link java is /usr/bin/java
slave java.1 is /usr/share/man/man1/java.1
slave java.1.gz is /usr/share/man/man1/java.1.gz
/snap/openjdk/current/jdk/bin/java - priority 2101
slave java.1: /snap/openjdk/current/jdk/man/man1/java.1
/usr/lib/jvm/java-11-openjdk-amd64/bin/java - priority 1111
slave java.1.gz: /usr/lib/jvm/java-11-openjdk-amd64/man/man1/java.1.gz
/usr/lib/jvm/java-17-openjdk-amd64/bin/java - priority 1711
slave java.1.gz: /usr/lib/jvm/java-17-openjdk-amd64/man/man1/java.1.gz The $ java --version
openjdk 21.0.1 2023-10-17
OpenJDK Runtime Environment (build 21.0.1+12-snap)
OpenJDK 64-Bit Server VM (build 21.0.1+12-snap, mixed mode, sharing)
$ man -w java
/snap/openjdk/1539/jdk/man/man1/java.1 I can look into adding a command, such as @inso99 If I can get something like this working well, would you be willing to test it? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having trouble installing this package via Ubuntu Software on Ubuntu 22.04/x64.
The installer completes, and everything seems ok in the Ubuntu Software Centre (no issues during installation, says "installed" afterwards).
But then when I run the command:
sudo update-alternatives --config java
no OpenJDK 21 shows up, just the previous versions already installed.
I try to restart the machine and run the same command, but still no OpenJDK 21 to be seen.
There is a user review in Ubuntu Software Center going by the nickname "bdsm" that said back in 25th of August 23 "kya bhai...! Launch hi nahi ho raha tera application", which I found is hindi translates to "What's up bro...! Your application is not launching", indicating that this is not a new problem, and that it has existed for users since at least 25th of August, meaning before OpenJDK 21 was released, ie. also affecting previous releases.
Beta Was this translation helpful? Give feedback.
All reactions