在Ubuntu系统中安装JDK 17并配置环境变量,可以按照以下步骤进行:
打开终端,更新Ubuntu软件包列表:
sudo apt-get update
输出结果:
oem@oak:~/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/bin$ sudo apt-get update [sudo] oem 的密码: 命中:1 http://cn.archive.ubuntu.com/ubuntu focal InRelease 获取:2 http://cn.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] 获取:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] 获取:4 http://cn.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB] 获取:5 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [59.8 kB] 获取:6 http://cn.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [274 kB] 获取:7 http://cn.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [410 kB] 获取:8 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [95.7 kB] 获取:9 http://cn.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [944 B] 获取:10 http://cn.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [7,968 B] 获取:11 http://cn.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.5 kB] 获取:12 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [940 B] 已下载 1,216 kB,耗时 5秒 (251 kB/s) 正在读取软件包列表... 完成
安装OpenJDK 17:
sudo apt-get install openjdk-17-jdk
输出结果:
oem@oak:~/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/bin$ sudo apt-get install openjdk-17-jdk 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 将会同时安装下列软件: ca-certificates-java fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-17-jdk-headless openjdk-17-jre openjdk-17-jre-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev 建议安装: default-jre libice-doc libsm-doc libx11-doc libxcb-doc libxt-doc openjdk-17-demo openjdk-17-source visualvm fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei 下列【新】软件包将被安装: ca-certificates-java fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-17-jdk openjdk-17-jdk-headless openjdk-17-jre openjdk-17-jre-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev 升级了 0 个软件包,新安装了 21 个软件包,要卸载 0 个软件包,有 427 个软件包未被升级。 需要下载 290 MB 的归档。 解压缩后会消耗 461 MB 的额外空间。 您希望继续执行吗? [Y/n] Y 获取:1 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 java-common all 0.72 [6,816 B] 获取:2 http://cn.archive.ubuntu.com/ubuntu focal-updates/universe amd64 openjdk-17-jre-headless amd64 17.0.6+10-0ubuntu1~20.04.1 [43.6 MB] 获取:3 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 ca-certificates-java all 20190405ubuntu1 [12.2 kB] 获取:4 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 fonts-dejavu-extra all 2.37-1 [1,953 kB] 获取:5 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libatk-wrapper-java all 0.37.1-1 [53.0 kB] 获取:6 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libatk-wrapper-java-jni amd64 0.37.1-1 [45.1 kB] 获取:7 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 xorg-sgml-doctools all 1:1.11-1 [12.9 kB] 获取:8 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 x11proto-dev all 2019.2-1ubuntu1 [594 kB] 获取:9 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 x11proto-core-dev all 2019.2-1ubuntu1 [2,620 B] 获取:10 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libice-dev amd64 2:1.0.10-0ubuntu1 [47.8 kB] 获取:11 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libpthread-stubs0-dev amd64 0.4-1 [5,384 B] 获取:12 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libsm-dev amd64 2:1.2.3-1 [17.0 kB] 获取:13 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libxau-dev amd64 1:1.0.9-0ubuntu1 [9,552 B] 获取:14 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libxdmcp-dev amd64 1:1.1.3-0ubuntu1 [25.3 kB] 获取:15 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 xtrans-dev all 1.4.0-1 [68.9 kB] 获取:16 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libxcb1-dev amd64 1.14-2 [80.5 kB] 获取:17 http://cn.archive.ubuntu.com/ubuntu focal-updates/main amd64 libx11-dev amd64 2:1.6.9-2ubuntu1.2 [647 kB] 获取:18 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 libxt-dev amd64 1:1.1.5-1 [395 kB] 获取:19 http://cn.archive.ubuntu.com/ubuntu focal-updates/universe amd64 openjdk-17-jre amd64 17.0.6+10-0ubuntu1~20.04.1 [166 kB] 获取:20 http://cn.archive.ubuntu.com/ubuntu focal-updates/universe amd64 openjdk-17-jdk-headless amd64 17.0.6+10-0ubuntu1~20.04.1 [243 MB] 获取:21 http://cn.archive.ubuntu.com/ubuntu focal-updates/universe amd64 openjdk-17-jdk amd64 17.0.6+10-0ubuntu1~20.04.1 [10.6 kB] a 已下载 290 MB,耗时 2分 1秒 (2,404 kB/s) 正在选中未选择的软件包 java-common。 (正在读取数据库 ... 系统当前共安装有 188161 个文件和目录。) 准备解压 .../00-java-common_0.72_all.deb ... 正在解压 java-common (0.72) ... 正在选中未选择的软件包 openjdk-17-jre-headless:amd64。 准备解压 .../01-openjdk-17-jre-headless_17.0.6+10-0ubuntu1~20.04.1_amd64.deb ... 正在解压 openjdk-17-jre-headless:amd64 (17.0.6+10-0ubuntu1~20.04.1) ... 正在选中未选择的软件包 ca-certificates-java。 准备解压 .../02-ca-certificates-java_20190405ubuntu1_all.deb ... 正在解压 ca-certificates-java (20190405ubuntu1) ... 正在选中未选择的软件包 fonts-dejavu-extra。 准备解压 .../03-fonts-dejavu-extra_2.37-1_all.deb ... 正在解压 fonts-dejavu-extra (2.37-1) ... 正在选中未选择的软件包 libatk-wrapper-java。 准备解压 .../04-libatk-wrapper-java_0.37.1-1_all.deb ... 正在解压 libatk-wrapper-java (0.37.1-1) ... 正在选中未选择的软件包 libatk-wrapper-java-jni:amd64。 准备解压 .../05-libatk-wrapper-java-jni_0.37.1-1_amd64.deb ... 正在解压 libatk-wrapper-java-jni:amd64 (0.37.1-1) ... 正在选中未选择的软件包 xorg-sgml-doctools。 准备解压 .../06-xorg-sgml-doctools_1%3a1.11-1_all.deb ... 正在解压 xorg-sgml-doctools (1:1.11-1) ... 正在选中未选择的软件包 x11proto-dev。 准备解压 .../07-x11proto-dev_2019.2-1ubuntu1_all.deb ... 正在解压 x11proto-dev (2019.2-1ubuntu1) ... 正在选中未选择的软件包 x11proto-core-dev。 准备解压 .../08-x11proto-core-dev_2019.2-1ubuntu1_all.deb ... 正在解压 x11proto-core-dev (2019.2-1ubuntu1) ... 正在选中未选择的软件包 libice-dev:amd64。 准备解压 .../09-libice-dev_2%3a1.0.10-0ubuntu1_amd64.deb ... 正在解压 libice-dev:amd64 (2:1.0.10-0ubuntu1) ... 正在选中未选择的软件包 libpthread-stubs0-dev:amd64。 准备解压 .../10-libpthread-stubs0-dev_0.4-1_amd64.deb ... 正在解压 libpthread-stubs0-dev:amd64 (0.4-1) ... 正在选中未选择的软件包 libsm-dev:amd64。 准备解压 .../11-libsm-dev_2%3a1.2.3-1_amd64.deb ... 正在解压 libsm-dev:amd64 (2:1.2.3-1) ... 正在选中未选择的软件包 libxau-dev:amd64。 准备解压 .../12-libxau-dev_1%3a1.0.9-0ubuntu1_amd64.deb ... 正在解压 libxau-dev:amd64 (1:1.0.9-0ubuntu1) ... 正在选中未选择的软件包 libxdmcp-dev:amd64。 准备解压 .../13-libxdmcp-dev_1%3a1.1.3-0ubuntu1_amd64.deb ... 正在解压 libxdmcp-dev:amd64 (1:1.1.3-0ubuntu1) ... 正在选中未选择的软件包 xtrans-dev。 准备解压 .../14-xtrans-dev_1.4.0-1_all.deb ... 正在解压 xtrans-dev (1.4.0-1) ... 正在选中未选择的软件包 libxcb1-dev:amd64。 准备解压 .../15-libxcb1-dev_1.14-2_amd64.deb ... 正在解压 libxcb1-dev:amd64 (1.14-2) ... 正在选中未选择的软件包 libx11-dev:amd64。 准备解压 .../16-libx11-dev_2%3a1.6.9-2ubuntu1.2_amd64.deb ... 正在解压 libx11-dev:amd64 (2:1.6.9-2ubuntu1.2) ... 正在选中未选择的软件包 libxt-dev:amd64。 准备解压 .../17-libxt-dev_1%3a1.1.5-1_amd64.deb ... 正在解压 libxt-dev:amd64 (1:1.1.5-1) ... 正在选中未选择的软件包 openjdk-17-jre:amd64。 准备解压 .../18-openjdk-17-jre_17.0.6+10-0ubuntu1~20.04.1_amd64.deb ... 正在解压 openjdk-17-jre:amd64 (17.0.6+10-0ubuntu1~20.04.1) ... 正在选中未选择的软件包 openjdk-17-jdk-headless:amd64。 准备解压 .../19-openjdk-17-jdk-headless_17.0.6+10-0ubuntu1~20.04.1_amd64.deb ... 正在解压 openjdk-17-jdk-headless:amd64 (17.0.6+10-0ubuntu1~20.04.1) ... 正在选中未选择的软件包 openjdk-17-jdk:amd64。 准备解压 .../20-openjdk-17-jdk_17.0.6+10-0ubuntu1~20.04.1_amd64.deb ... 正在解压 openjdk-17-jdk:amd64 (17.0.6+10-0ubuntu1~20.04.1) ... 正在设置 java-common (0.72) ... 正在设置 libpthread-stubs0-dev:amd64 (0.4-1) ... 正在设置 xtrans-dev (1.4.0-1) ... 正在设置 fonts-dejavu-extra (2.37-1) ... 正在设置 xorg-sgml-doctools (1:1.11-1) ... 正在设置 libatk-wrapper-java (0.37.1-1) ... 正在设置 libatk-wrapper-java-jni:amd64 (0.37.1-1) ... 正在设置 openjdk-17-jre-headless:amd64 (17.0.6+10-0ubuntu1~20.04.1) ... update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/java 来在自动模式中提供 /usr/bin/java (java) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jpackage 来在自动模式中提供 /usr/bin/jpackage (jpackage) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/keytool 来在自动模式中提供 /usr/bin/keytool (keytool) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/rmiregistry 来在自动模式中提供 /usr/bin/rmiregistry (rmiregistry) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/lib/jexec 来在自动模式中提供 /usr/bin/jexec (jexec) 正在设置 ca-certificates-java (20190405ubuntu1) ... head: 无法打开'/etc/ssl/certs/java/cacerts' 读取数据: 没有那个文件或目录 Adding debian:TeliaSonera_Root_CA_v1.pem Adding debian:Microsec_e-Szigno_Root_CA_2009.pem Adding debian:emSign_Root_CA_-_G1.pem Adding debian:Entrust_Root_Certification_Authority_-_G4.pem Adding debian:QuoVadis_Root_CA_1_G3.pem Adding debian:EC-ACC.pem Adding debian:CFCA_EV_ROOT.pem Adding debian:Amazon_Root_CA_2.pem Adding debian:Certum_Trusted_Network_CA_2.pem Adding debian:Trustis_FPS_Root_CA.pem Adding debian:Microsoft_RSA_Root_Certificate_Authority_2017.pem Adding debian:T-TeleSec_GlobalRoot_Class_2.pem Adding debian:Security_Communication_RootCA2.pem Adding debian:Hongkong_Post_Root_CA_3.pem Adding debian:COMODO_Certification_Authority.pem Adding debian:ACCVRAIZ1.pem Adding debian:Certum_Trusted_Network_CA.pem Adding debian:ISRG_Root_X1.pem Adding debian:GDCA_TrustAUTH_R5_ROOT.pem Adding debian:Hongkong_Post_Root_CA_1.pem Adding debian:Comodo_AAA_Services_root.pem Adding debian:Amazon_Root_CA_4.pem Adding debian:Microsoft_ECC_Root_Certificate_Authority_2017.pem Adding debian:DigiCert_High_Assurance_EV_Root_CA.pem Adding debian:D-TRUST_Root_Class_3_CA_2_2009.pem Adding debian:TWCA_Root_Certification_Authority.pem Adding debian:Go_Daddy_Class_2_CA.pem Adding debian:GlobalSign_ECC_Root_CA_-_R5.pem Adding debian:IdenTrust_Public_Sector_Root_CA_1.pem Adding debian:QuoVadis_Root_CA_2.pem Adding debian:AC_RAIZ_FNMT-RCM.pem Adding debian:SZAFIR_ROOT_CA2.pem Adding debian:emSign_Root_CA_-_C1.pem Adding debian:Buypass_Class_2_Root_CA.pem Adding debian:SecureSign_RootCA11.pem Adding debian:Amazon_Root_CA_1.pem Adding debian:certSIGN_ROOT_CA.pem Adding debian:Global_Chambersign_Root_-_2008.pem Adding debian:DigiCert_Global_Root_CA.pem Adding debian:SwissSign_Silver_CA_-_G2.pem Adding debian:SSL.com_Root_Certification_Authority_RSA.pem Adding debian:Trustwave_Global_Certification_Authority.pem Adding debian:GlobalSign_Root_CA_-_R2.pem Adding debian:GeoTrust_Primary_Certification_Authority_-_G2.pem Adding debian:Baltimore_CyberTrust_Root.pem Adding debian:GlobalSign_Root_CA.pem Adding debian:CA_Disig_Root_R2.pem Adding debian:VeriSign_Universal_Root_Certification_Authority.pem Adding debian:Trustwave_Global_ECC_P256_Certification_Authority.pem Adding debian:COMODO_RSA_Certification_Authority.pem Adding debian:DigiCert_Global_Root_G2.pem Adding debian:Autoridad_de_Certificacion_Firmaprofesional_CIF_A62634068.pem Adding debian:D-TRUST_Root_Class_3_CA_2_EV_2009.pem Adding debian:DST_Root_CA_X3.pem Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2015.pem Adding debian:Entrust.net_Premium_2048_Secure_Server_CA.pem Adding debian:Starfield_Root_Certificate_Authority_-_G2.pem Adding debian:SecureTrust_CA.pem Adding debian:QuoVadis_Root_CA_3.pem Adding debian:AffirmTrust_Premium_ECC.pem Adding debian:Sonera_Class_2_Root_CA.pem Adding debian:GlobalSign_Root_CA_-_R3.pem Adding debian:AffirmTrust_Networking.pem Adding debian:Hellenic_Academic_and_Research_Institutions_ECC_RootCA_2015.pem Adding debian:AffirmTrust_Premium.pem Adding debian:TrustCor_RootCert_CA-2.pem Adding debian:QuoVadis_Root_CA_3_G3.pem Adding debian:Entrust_Root_Certification_Authority.pem Adding debian:Network_Solutions_Certificate_Authority.pem Adding debian:Starfield_Class_2_CA.pem Adding debian:DigiCert_Global_Root_G3.pem Adding debian:SSL.com_EV_Root_Certification_Authority_ECC.pem Adding debian:Entrust_Root_Certification_Authority_-_EC1.pem Adding debian:Go_Daddy_Root_Certificate_Authority_-_G2.pem Adding debian:DigiCert_Trusted_Root_G4.pem Adding debian:GTS_Root_R1.pem Adding debian:ePKI_Root_Certification_Authority.pem Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2011.pem Adding debian:DigiCert_Assured_ID_Root_G3.pem Adding debian:DigiCert_Assured_ID_Root_CA.pem Adding debian:TUBITAK_Kamu_SM_SSL_Kok_Sertifikasi_-_Surum_1.pem Adding debian:XRamp_Global_CA_Root.pem Adding debian:TrustCor_RootCert_CA-1.pem Adding debian:Amazon_Root_CA_3.pem Adding debian:Staat_der_Nederlanden_EV_Root_CA.pem Adding debian:Starfield_Services_Root_Certificate_Authority_-_G2.pem Adding debian:GlobalSign_ECC_Root_CA_-_R4.pem Adding debian:Certigna.pem Adding debian:GTS_Root_R3.pem Adding debian:ssl-cert-snakeoil.pem Adding debian:Actalis_Authentication_Root_CA.pem Adding debian:IdenTrust_Commercial_Root_CA_1.pem Adding debian:USERTrust_ECC_Certification_Authority.pem Adding debian:UCA_Global_G2_Root.pem Adding debian:Trustwave_Global_ECC_P384_Certification_Authority.pem Adding debian:Certigna_Root_CA.pem Adding debian:T-TeleSec_GlobalRoot_Class_3.pem Adding debian:Buypass_Class_3_Root_CA.pem Adding debian:emSign_ECC_Root_CA_-_G3.pem Adding debian:DigiCert_Assured_ID_Root_G2.pem Adding debian:e-Szigno_Root_CA_2017.pem Adding debian:UCA_Extended_Validation_Root.pem Adding debian:QuoVadis_Root_CA.pem Adding debian:NAVER_Global_Root_Certification_Authority.pem Adding debian:TrustCor_ECA-1.pem Adding debian:Izenpe.com.pem Adding debian:COMODO_ECC_Certification_Authority.pem Adding debian:Cybertrust_Global_Root.pem Adding debian:E-Tugra_Certification_Authority.pem Adding debian:NetLock_Arany_=Class_Gold=_Főtanúsítvány.pem Adding debian:QuoVadis_Root_CA_2_G3.pem Adding debian:USERTrust_RSA_Certification_Authority.pem Adding debian:SSL.com_EV_Root_Certification_Authority_RSA_R2.pem Adding debian:SwissSign_Gold_CA_-_G2.pem Adding debian:emSign_ECC_Root_CA_-_C3.pem Adding debian:AffirmTrust_Commercial.pem Adding debian:Staat_der_Nederlanden_Root_CA_-_G3.pem Adding debian:Security_Communication_Root_CA.pem Adding debian:Chambers_of_Commerce_Root_-_2008.pem Adding debian:GlobalSign_Root_CA_-_R6.pem Adding debian:certSIGN_Root_CA_G2.pem Adding debian:OISTE_WISeKey_Global_Root_GB_CA.pem Adding debian:Entrust_Root_Certification_Authority_-_G2.pem Adding debian:SSL.com_Root_Certification_Authority_ECC.pem Adding debian:TWCA_Global_Root_CA.pem Adding debian:Secure_Global_CA.pem Adding debian:GTS_Root_R4.pem Adding debian:GTS_Root_R2.pem Adding debian:Atos_TrustedRoot_2011.pem Adding debian:OISTE_WISeKey_Global_Root_GC_CA.pem done. 正在设置 openjdk-17-jre:amd64 (17.0.6+10-0ubuntu1~20.04.1) ... 正在设置 openjdk-17-jdk-headless:amd64 (17.0.6+10-0ubuntu1~20.04.1) ... update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jar 来在自动模式中提供 /usr/bin/jar (jar) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jarsigner 来在自动模式中提供 /usr/bin/jarsigner (jarsigner) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/javac 来在自动模式中提供 /usr/bin/javac (javac) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/javadoc 来在自动模式中提供 /usr/bin/javadoc (javadoc) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/javap 来在自动模式中提供 /usr/bin/javap (javap) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jcmd 来在自动模式中提供 /usr/bin/jcmd (jcmd) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jdb 来在自动模式中提供 /usr/bin/jdb (jdb) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jdeprscan 来在自动模式中提供 /usr/bin/jdeprscan (jdeprscan) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jdeps 来在自动模式中提供 /usr/bin/jdeps (jdeps) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jfr 来在自动模式中提供 /usr/bin/jfr (jfr) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jimage 来在自动模式中提供 /usr/bin/jimage (jimage) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jinfo 来在自动模式中提供 /usr/bin/jinfo (jinfo) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jlink 来在自动模式中提供 /usr/bin/jlink (jlink) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jmap 来在自动模式中提供 /usr/bin/jmap (jmap) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jmod 来在自动模式中提供 /usr/bin/jmod (jmod) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jps 来在自动模式中提供 /usr/bin/jps (jps) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jrunscript 来在自动模式中提供 /usr/bin/jrunscript (jrunscript) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jshell 来在自动模式中提供 /usr/bin/jshell (jshell) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jstack 来在自动模式中提供 /usr/bin/jstack (jstack) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jstat 来在自动模式中提供 /usr/bin/jstat (jstat) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jstatd 来在自动模式中提供 /usr/bin/jstatd (jstatd) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/serialver 来在自动模式中提供 /usr/bin/serialver (serialver) update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jhsdb 来在自动模式中提供 /usr/bin/jhsdb (jhsdb) 正在设置 openjdk-17-jdk:amd64 (17.0.6+10-0ubuntu1~20.04.1) ... update-alternatives: 使用 /usr/lib/jvm/java-17-openjdk-amd64/bin/jconsole 来在自动模式中提供 /usr/bin/jconsole (jconsole) 正在处理用于 ca-certificates (20210119~20.04.1) 的触发器 ... Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. done. 正在处理用于 sgml-base (1.29.1) 的触发器 ... 正在设置 x11proto-dev (2019.2-1ubuntu1) ... 正在处理用于 fontconfig (2.13.1-2ubuntu3) 的触发器 ... 正在处理用于 desktop-file-utils (0.24-1ubuntu3) 的触发器 ... 正在处理用于 mime-support (3.64ubuntu1) 的触发器 ... 正在设置 libxau-dev:amd64 (1:1.0.9-0ubuntu1) ... 正在处理用于 hicolor-icon-theme (0.17-2) 的触发器 ... 正在设置 libice-dev:amd64 (2:1.0.10-0ubuntu1) ... 正在处理用于 gnome-menus (3.36.0-1ubuntu1) 的触发器 ... 正在设置 libsm-dev:amd64 (2:1.2.3-1) ... 正在处理用于 man-db (2.9.1-1) 的触发器 ... 正在设置 libxdmcp-dev:amd64 (1:1.1.3-0ubuntu1) ... 正在设置 x11proto-core-dev (2019.2-1ubuntu1) ... 正在设置 libxcb1-dev:amd64 (1.14-2) ... 正在设置 libx11-dev:amd64 (2:1.6.9-2ubuntu1.2) ... 正在设置 libxt-dev:amd64 (1:1.1.5-1) ... oem@oak:~/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/bin$
如果您更喜欢Oracle JDK,可以下载适用于Ubuntu的二进制文件,然后安装它。可以在Oracle网站上找到JDK下载链接。
检查JDK是否正确安装:
java -version
oem@oak:~/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.8770.65/bin$ java -version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment (build 17.0.6+10-Ubuntu-0ubuntu120.04.1)
OpenJDK 64-Bit Server VM (build 17.0.6+10-Ubuntu-0ubuntu120.04.1, mixed mode, sharing
如果JDK成功安装,则会在终端上显示JDK版本信息。
配置环境变量:
打开/etc/environment文件:
sudo nano /etc/environment
在文件末尾添加以下行:
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
PATH=$PATH:$JAVA_HOME/bin
这里假设您使用的是OpenJDK 17,如果您使用的是Oracle JDK,请将JAVA_HOME路径更改为相应的路径。
保存并关闭文件。
更新环境变量:
source /etc/environment
检查环境变量是否正确配置:
echo $JAVA_HOME
echo $PATH
如果环境变量已正确配置,则会在终端上显示JAVA_HOME和PATH的值。
以上步骤完成后,您就成功安装了JDK 17并配置了环境变量。文章来源:https://www.toymoban.com/news/detail-436596.html
结语
如果这篇文章对您有所帮助,或者有所启发的话,求一键三连:点赞、评论、收藏➕关注,您的支持是我坚持写作最大的动力。文章来源地址https://www.toymoban.com/news/detail-436596.html
到了这里,关于在Ubuntu系统中安装JDK 17并配置环境变量的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!