ubuntu 中配置java環境(線上軟體包)
阿新 • • 發佈:2021-10-21
1、核心版本
root@ubuntu02:~# hostnamectl Static hostname: ubuntu02 Icon name: computer-vm Chassis: vm Machine ID: 3c186d21e7094b71a8889a2d78350c4b Boot ID: cc8cf35b8ad54b68a5a2f07eb4042153 Virtualization: vmware Operating System: Ubuntu 20.04.3 LTS Kernel: Linux5.11.0-38-generic Architecture: x86-64
2、測試java
root@ubuntu02:~# java Command 'java' not found, but can be installed with: apt install openjdk-11-jre-headless # version 11.0.11+9-0ubuntu2~20.04, or apt install default-jre # version 2:1.11-72 apt install openjdk-13-jre-headless # version 13.0.7+5-0ubuntu1~20.04 apt install openjdk-16-jre-headless # version 16.0.1+9-1~20.04 apt install openjdk-17-jre-headless # version 17+35-1~20.04 apt install openjdk-8-jre-headless # version 8u292-b10-0ubuntu1~20.04
root@ubuntu02:~# java --version Command 'java' not found, but can be installed with: apt install openjdk-11-jre-headless # version 11.0.11+9-0ubuntu2~20.04, or apt install default-jre # version 2:1.11-72 apt install openjdk-13-jre-headless # version 13.0.7+5-0ubuntu1~20.04 apt install openjdk-16-jre-headless # version 16.0.1+9-1~20.04 apt install openjdk-17-jre-headless # version 17+35-1~20.04 apt install openjdk-8-jre-headless # version 8u292-b10-0ubuntu1~20.04
3、直接安裝
root@ubuntu02:~# apt install openjdk-11-jre-headless Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: ca-certificates-java java-common Suggested packages: default-jre fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei The following NEW packages will be installed: ………… Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. done.
4、測試效果
root@ubuntu02:~# java -v // ????? Unrecognized option: -v Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. root@ubuntu02:~# java --version openjdk 11.0.11 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing) root@ubuntu02:~#