Debian 11 Bullseye
Sponsored Link

OpenJDK 11 : Install2021/09/23

 
Install OpenJDK.
[1] Install OpenJDK 11. If you need only JRE, Install only [openjdk-11-jre] package.
root@dlp:~#
apt -y install openjdk-11-jdk
root@dlp:~#
cat > /etc/profile.d/java.sh <<'EOF'
export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which java)))))
export PATH=$PATH:$JAVA_HOME/bin
EOF
root@dlp:~#
source /etc/profile.d/java.sh
root@dlp:~#
java --version

openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2)
OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)

# verify to create test program

root@dlp:~# cat > java_test.java <<'EOF'
class java_test {
    public static void main(String[] args) {
        System.out.println("Hello Java World !");
    }
}
EOF 

root@dlp:~#
javac java_test.java

root@dlp:~#
java java_test

Hello Java World !
[2] If you installed multiple version of Java from official repository, it's possible to switch them with [alternatives].
root@dlp:~#
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-17-openjdk-amd64/bin/java   1711      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
  2            /usr/lib/jvm/java-17-openjdk-amd64/bin/java   1711      manual mode

Press <enter> to keep the current choice[*], or type selection number: 1

root@dlp:~#
update-alternatives --config javac

There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                          Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-17-openjdk-amd64/bin/javac   1711      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/javac   1111      manual mode
  2            /usr/lib/jvm/java-17-openjdk-amd64/bin/javac   1711      manual mode

Press <enter> to keep the current choice[*], or type selection number: 1

root@dlp:~#
java --version

openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2)
OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)
Matched Content