In Debian Stable the latest openjdk
version available is 17
.
$ which -a java
/usr/bin/java
/bin/java
$ java --version
openjdk 17.0.8 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Debian-1deb12u1, mixed mode, sharing)
I wanted to test out 21
which will be released soon so I downloaded the binaries directly.
$ curl https://download.java.net/java/GA/jdk21/fd2272bbf8e04c3dbaee13770090416c/35/GPL/openjdk-21_linux-x64_bin.tar.gz
$ tar -xzf openjdk-21_linux-x64_bin.tar.gz
$ cd jdk-21
$ ./bin/java --version
openjdk 21 2023-09-19
OpenJDK Runtime Environment (build 21+35-2513)
OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)
$ which -a java
/usr/bin/java
/bin/java
$ java --version
openjdk 17.0.8 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Debian-1deb12u1, mixed mode, sharing)
I would like all my scripts to use the new java binaries without having to manually edit all java
entries in them. That is, when invoking java
I would like the new binaries to run. Can I replace stock java
by simply copy pasting to /usr/bin/
and /bin/
? That is, will this work?
$ mv ./bin/* /usr/bin/
$ mv ./bin/* /bin/
Do I also need to copy other folders in jdk-21
such as conf
and lib
? Can replacing stock java cause any side effects?