feature request: Provide a way to install without changing system default Java via update-alternatives
davidxia opened this issue · 6 comments
Is your feature request related to a problem?
I have a host running multiple Java processes. I want to migrate one of them to be run by Java 11, but the other processes aren't compatible with Java 11. These processes are started with java
which depends on the system default java. I don't control the startup commands for these processes.
I'd like to install the Corretto 11 Debian package without it changing my system's default Java via update-alternatives
. That way I can install the package, change the startup command for my one process I want to migrate with the exact path to the Corretto 11 JVM executable, and leave the other processes untouched.
Describe a solution you would like
There should be a way to install the Corretto 11 Debian package without it changing my system's default Java via update-alternatives
. It could be a separate Debian package called java-11-amazon-corretto-jdk:amd64-no-alt
or the same package and some parameter that disables update-alternatives. I don't have a preference right now.
Describe alternatives you have considered
I could work around the update-alternatives by writing a script that saves the system's current default Java, installing Corretto 11, then run update-alternatives
to restore the original Java version. Downsides
- there's a chance the processes incompatible with Java 11 might restart during this time
- I manage thousands of hosts with puppet and this is not very maintainable or elegant
I could also try to modify the startup commands of all the other Java processes so that they explicitly use an absolute path to the compatible JVM executable, but this is tedious and brittle.
Thanks for contacting us about this.
We'll look into providing an alternative package or making this an install-time option for a future release.
In the meantime, there are a few possible workarounds.
First, if installing through a package manager is not a requirement, you can download Corretto 11 as a .tar.gz and install to the location of your choice. In this situation update-alternatives
will not be run.
Second, if building your own .deb
packages is feasible in the short term, you can modify the packaging script to not run update-alternatives
, or to only run it for certain components. Since update-alternatives
uses a priority system, you could also consider modifying the priority to a lower value than the existing Java 8 installation.
The third possible workaround is a modification of the alternative you've described.
Rather than running update-alternatives
on each host after installing Java 11, you can set it to manual mode before you install Java 11. If update-java-alternatives
is available on your systems, this is as simple as update-java-alternatives -s java-1.8.0-amazon-corretto
to set the default to Corretto 8.
Here's an example from an Ubuntu docker container:
root@af12f831f67d:/# update-alternatives --display java
java - auto mode
link best version is /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/bin/java
link currently points to /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/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
/usr/lib/jvm/java-1.8.0-amazon-corretto/jre/bin/java - priority 10800252
slave java.1: /usr/lib/jvm/java-1.8.0-amazon-corretto/man/man1/java.1
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081
slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz
root@af12f831f67d:/# update-java-alternatives -s java-1.8.0-amazon-corretto
update-alternatives: error: no alternatives for mozilla-javaplugin.so
root@af12f831f67d:/# update-alternatives --display java
java - manual mode
link best version is /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/bin/java
link currently points to /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/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
/usr/lib/jvm/java-1.8.0-amazon-corretto/jre/bin/java - priority 10800252
slave java.1: /usr/lib/jvm/java-1.8.0-amazon-corretto/man/man1/java.1
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081
slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz
root@af12f831f67d:/# dpkg -i amazon-corretto-11-x64-linux-jdk.deb
Selecting previously unselected package java-11-amazon-corretto-jdk:amd64.
(Reading database ... 23454 files and directories currently installed.)
Preparing to unpack amazon-corretto-11-x64-linux-jdk.deb ...
Unpacking java-11-amazon-corretto-jdk:amd64 (1:11.0.7.10-1) ...
Setting up java-11-amazon-corretto-jdk:amd64 (1:11.0.7.10-1) ...
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jaotc to provide /usr/bin/jaotc (jaotc) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jlink to provide /usr/bin/jlink (jlink) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jmod to provide /usr/bin/jmod (jmod) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jhsdb to provide /usr/bin/jhsdb (jhsdb) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jdeprscan to provide /usr/bin/jdeprscan (jdeprscan) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jimage to provide /usr/bin/jimage (jimage) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jshell to provide /usr/bin/jshell (jshell) in auto mode
root@af12f831f67d:/# update-alternatives --display java
java - manual mode
link best version is /usr/lib/jvm/java-11-amazon-corretto/bin/java
link currently points to /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/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
/usr/lib/jvm/java-1.8.0-amazon-corretto/jre/bin/java - priority 10800252
slave java.1: /usr/lib/jvm/java-1.8.0-amazon-corretto/man/man1/java.1
/usr/lib/jvm/java-11-amazon-corretto/bin/java - priority 11100007
slave java.1: /usr/lib/jvm/java-11-amazon-corretto/man/man1/java.1
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081
slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz
root@af12f831f67d:/# java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment Corretto-8.252.09.1 (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM Corretto-8.252.09.1 (build 25.252-b09, mixed mode)
As you can see, in this situation the only resources updated by the Java 11 installation are those not provided by Java 8.
@benty-amzn thanks so much for the suggestions. The third approach works best for us and works! Any idea or rough timeline for the deb package that'll support the install-time option?
dxia@guc3-heliosagent-c-mj43:~$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
dxia@guc3-heliosagent-c-mj43:~$ dpkg -l | grep java
ii ca-certificates-java 20180516ubuntu1~18.04.1 all Common CA certificates (JKS keystore)
ii default-jdk 3:1.8-60~0.0.0.12.c982fea.8 amd64 Default JDK for Spotify (oracle-java8-jdk)
ii default-jre-headless 3:1.8-60~0.0.0.12.c982fea.8 amd64 Default headless JRE for Spotify (oracle-java8-jdk)
ii java-common 0.68ubuntu1~18.04.1 all Base package for Java runtimes
ii javascript-common 11 all Base support for JavaScript library packages
ii oracle-java8-jdk 8u162-spotify14 amd64 Java Platform, Standard Edition 8 Development Kit
ii oracle-java8-jdk-no-alt 8u102-spotify8 amd64 Java™ Platform, Standard Edition 8 Development Kit
dxia@guc3-heliosagent-c-mj43:~$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/oracle-java8-jdk-amd64/jre/bin/java
Nothing to configure.
dxia@guc3-heliosagent-c-mj43:~$ sudo /usr/sbin/update-java-alternatives --list
jdk-8-oracle-x64-no-alt 318 /usr/lib/jvm/jdk-8-oracle-x64-no-alt
oracle-java8-jdk-amd64 318 /usr/lib/jvm/oracle-java8-jdk-amd64
dxia@guc3-heliosagent-c-mj43:~$ sudo /usr/sbin/update-java-alternatives --set oracle-java8-jdk-amd64
dxia@guc3-heliosagent-c-mj43:~$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
dxia@guc3-heliosagent-c-mj43:~$ sudo /usr/sbin/update-java-alternatives --list
jdk-8-oracle-x64-no-alt 318 /usr/lib/jvm/jdk-8-oracle-x64-no-alt
oracle-java8-jdk-amd64 318 /usr/lib/jvm/oracle-java8-jdk-amd64
dxia@guc3-heliosagent-c-mj43:~$ sudo update-alternatives --config java
There is 1 choice for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/oracle-java8-jdk-amd64/jre/bin/java 318 auto mode
* 1 /usr/lib/jvm/oracle-java8-jdk-amd64/jre/bin/java 318 manual mode
Press <enter> to keep the current choice[*], or type selection number: ^C
dxia@guc3-heliosagent-c-mj43:~$ sudo apt-get install java-11-amazon-corretto-jdk:amd64
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
java-11-amazon-corretto-jdk
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 192 MB of archives.
After this operation, 321 MB of additional disk space will be used.
Get:1 http://debmirror:9888/corretto stable/main amd64 java-11-amazon-corretto-jdk amd64 1:11.0.7.10-1 [192 MB]
12% [1 java-11-amazon-corretto-jdk 29.5 MB/192 MB 15%]
Fetched 192 MB in 5s (42.3 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package java-11-amazon-corretto-jdk:amd64.
(Reading database ... 134742 files and directories currently installed.)
Preparing to unpack .../java-11-amazon-corretto-jdk_1%3a11.0.7.10-1_amd64.deb ...
Unpacking java-11-amazon-corretto-jdk:amd64 (1:11.0.7.10-1) ...
Setting up java-11-amazon-corretto-jdk:amd64 (1:11.0.7.10-1) ...
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jjs to provide /usr/bin/jjs (jjs) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jaotc to provide /usr/bin/jaotc (jaotc) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jlink to provide /usr/bin/jlink (jlink) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jmod to provide /usr/bin/jmod (jmod) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jhsdb to provide /usr/bin/jhsdb (jhsdb) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jdeprscan to provide /usr/bin/jdeprscan (jdeprscan) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jimage to provide /usr/bin/jimage (jimage) in auto mode
update-alternatives: using /usr/lib/jvm/java-11-amazon-corretto/bin/jshell to provide /usr/bin/jshell (jshell) in auto mode
dxia@guc3-heliosagent-c-mj43:~$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
dxia@guc3-heliosagent-c-mj43:~$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-amazon-corretto/bin/java 11100007 auto mode
1 /usr/lib/jvm/java-11-amazon-corretto/bin/java 11100007 manual mode
* 2 /usr/lib/jvm/oracle-java8-jdk-amd64/jre/bin/java 318 manual mode
This feature request would also be good to have for the Java 8 Corretto package since we're going to be using that as well.
@benty-amzn hi, just bumping to see if there's any rough timeline. Would it help if we sent a PR? If so, any guidance would be great. Thanks!
After investigation, we have determined that the priorities set by both Corretto 8 and Corretto 11 (10800252 and 11100007 respectively) are very high compared to other JDK distributions.
However, the relative priority between the two versions is consistent with the behavior of other jdk distributions.
For example, the jdk packages in Ubuntu Xenial set a priority of 1111 for jdk version 11 and 1081 for jdk version 8; these values are consistent with the priorities used by other jdk distributions in their .deb packages.
At this point, we believe the best approach is to leave the .deb
packages as-is, and recommend that you set update-alternatives
to manual mode before installing Corretto. Alternatively, you could install Corretto through other means such as the .tar.gz
bundles available on the Corretto releases page.
Thanks. Closing then.