1.下载并上传到服务器:https://www.oracle.com/java/technologies/downloads/#java21
2.执行命令安装
dpkg -i jdk-22_linux-x64_bin.deb
从以上截图看出,无需设置环境变量,已经自动好了
官方文档:
Installing the 64-Bit JDK Package on Debian-based Linux Platforms
You can install the JDK Debian package for 64-bit Linux from the (.deb) file.
To install the 64-bit JDK Debian package on a Linux platform:
Download the required file:
jdk-22.interim.update.patch_linux-x64_bin.deb. For example jdk-22_linux-x64_bin.deb
Before you download a file, you must accept the license agreement. Anyone (not only root users) can install the archive file in any location having write access.
Install the package using the following command:
$ sudo dpkg -i jdk-22_linux-x64_bin.deb
The Java Development Kit files are installed into /usr/lib/jvm/jdk-<FEATURE>-oracle-<ARCH> directory. For example, JDK 22 releases for x64 will be installed in /usr/lib/jvm/jdk-22-oracle-x64 directory.
Delete the .deb file if you want to save disk space.