登录  /  注册
博主信息
博文 291
粉丝 0
评论 0
访问量 432315
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
Ubuntu Linux 安装配置JDK17开发环境
原创
1172人浏览过

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

1、查看linux系统信息,并升级系统

file

file

$ cat /etc/os-release

$ lsb_release -a

$ uname -a

$ sudo apt update

$ sudo apt list —upgradable

$ sudo apt upgrade -y

  1. webrx@us:~$ cat /etc/os-release
  2. NAME="Ubuntu"
  3. VERSION="20.04.3 LTS (Focal Fossa)"
  4. ID=ubuntu
  5. ID_LIKE=debian
  6. PRETTY_NAME="Ubuntu 20.04.3 LTS"
  7. VERSION_ID="20.04"
  8. HOME_URL="https://www.ubuntu.com/"
  9. SUPPORT_URL="https://help.ubuntu.com/"
  10. BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
  11. PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
  12. VERSION_CODENAME=focal
  13. UBUNTU_CODENAME=focal
  14. webrx@us:~$ sudo apt update
  15. [sudo] password for webrx:
  16. Hit:1 http://mirrors.aliyun.com/ubuntu focal InRelease
  17. Get:2 http://mirrors.aliyun.com/ubuntu focal-updates InRelease [114 kB]
  18. Get:3 http://mirrors.aliyun.com/ubuntu focal-backports InRelease [101 kB]
  19. Get:4 http://mirrors.aliyun.com/ubuntu focal-security InRelease [114 kB]
  20. Get:5 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 Packages [1,258 kB]
  21. Hit:6 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease
  22. Get:7 http://mirrors.aliyun.com/ubuntu focal-updates/main Translation-en [265 kB]
  23. Get:8 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 c-n-f Metadata [14.4 kB]
  24. Get:9 http://mirrors.aliyun.com/ubuntu focal-updates/restricted amd64 Packages [486 kB]
  25. Get:10 http://mirrors.aliyun.com/ubuntu focal-updates/restricted Translation-en [69.6 kB]
  26. Get:11 http://mirrors.aliyun.com/ubuntu focal-updates/universe amd64 Packages [865 kB]
  27. Get:12 http://mirrors.aliyun.com/ubuntu focal-updates/universe Translation-en [185 kB]
  28. Get:13 http://mirrors.aliyun.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [19.2 kB]
  29. Get:14 http://mirrors.aliyun.com/ubuntu focal-security/main amd64 Packages [909 kB]
  30. Get:15 http://mirrors.aliyun.com/ubuntu focal-security/main Translation-en [173 kB]
  31. Get:16 http://mirrors.aliyun.com/ubuntu focal-security/main amd64 c-n-f Metadata [8,820 B]
  32. Get:17 http://mirrors.aliyun.com/ubuntu focal-security/restricted amd64 Packages [447 kB]
  33. Get:18 http://mirrors.aliyun.com/ubuntu focal-security/restricted Translation-en [64.1 kB]
  34. Get:19 http://mirrors.aliyun.com/ubuntu focal-security/universe amd64 Packages [643 kB]
  35. Get:20 http://mirrors.aliyun.com/ubuntu focal-security/universe Translation-en [103 kB]
  36. Get:21 http://mirrors.aliyun.com/ubuntu focal-security/universe amd64 c-n-f Metadata [12.5 kB]
  37. Fetched 5,851 kB in 12s (470 kB/s)
  38. Reading package lists... Done
  39. Building dependency tree
  40. Reading state information... Done
  41. 11 packages can be upgraded. Run 'apt list --upgradable' to see them.
  42. webrx@us:~$ sudo apt list --upgradable
  43. Listing... Done
  44. distro-info-data/focal-updates,focal-security 0.43ubuntu1.8 all [upgradable from: 0.43ubuntu1.6]
  45. libpam-modules-bin/focal-updates 1.3.1-5ubuntu4.3 amd64 [upgradable from: 1.3.1-5ubuntu4.2]
  46. libpam-modules/focal-updates 1.3.1-5ubuntu4.3 amd64 [upgradable from: 1.3.1-5ubuntu4.2]
  47. libpam-runtime/focal-updates 1.3.1-5ubuntu4.3 all [upgradable from: 1.3.1-5ubuntu4.2]
  48. libpam0g/focal-updates 1.3.1-5ubuntu4.3 amd64 [upgradable from: 1.3.1-5ubuntu4.2]
  49. libpython3.8-minimal/focal-updates,focal-security 3.8.10-0ubuntu1~20.04.1 amd64 [upgradable from: 3.8.10-0ubuntu1~20.04]
  50. libpython3.8-stdlib/focal-updates,focal-security 3.8.10-0ubuntu1~20.04.1 amd64 [upgradable from: 3.8.10-0ubuntu1~20.04]
  51. libpython3.8/focal-updates,focal-security 3.8.10-0ubuntu1~20.04.1 amd64 [upgradable from: 3.8.10-0ubuntu1~20.04]
  52. python3.8-minimal/focal-updates,focal-security 3.8.10-0ubuntu1~20.04.1 amd64 [upgradable from: 3.8.10-0ubuntu1~20.04]
  53. python3.8/focal-updates,focal-security 3.8.10-0ubuntu1~20.04.1 amd64 [upgradable from: 3.8.10-0ubuntu1~20.04]
  54. tzdata/focal-updates,focal-security 2021a-2ubuntu0.20.04 all [upgradable from: 2021a-0ubuntu0.20.04]
  55. webrx@us:~$ sudo apt upgrade -y
  56. Reading package lists... Done
  57. Building dependency tree
  58. Reading state information... Done
  59. Calculating upgrade... Done
  60. The following packages will be upgraded:
  61. distro-info-data libpam-modules libpam-modules-bin libpam-runtime libpam0g libpython3.8
  62. libpython3.8-minimal libpython3.8-stdlib python3.8 python3.8-minimal tzdata
  63. 11 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  64. 7 standard security updates
  65. Need to get 6,999 kB of archives.
  66. After this operation, 2,048 B of additional disk space will be used.
  67. Get:1 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 libpam0g amd64 1.3.1-5ubuntu4.3 [55.4 kB]
  68. Get:2 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 libpam-modules-bin amd64 1.3.1-5ubuntu4.3 [41.2 kB]
  69. Get:3 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 libpam-modules amd64 1.3.1-5ubuntu4.3 [260 kB]
  70. Get:4 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 libpython3.8 amd64 3.8.10-0ubuntu1~20.04.1 [1,625 kB]
  71. Get:5 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 python3.8 amd64 3.8.10-0ubuntu1~20.04.1 [387 kB]
  72. Get:6 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 libpython3.8-stdlib amd64 3.8.10-0ubuntu1~20.04.1 [1,674 kB]
  73. Get:7 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 python3.8-minimal amd64 3.8.10-0ubuntu1~20.04.1 [1,900 kB]
  74. Get:8 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 libpython3.8-minimal amd64 3.8.10-0ubuntu1~20.04.1 [717 kB]
  75. Get:9 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 libpam-runtime all 1.3.1-5ubuntu4.3 [37.3 kB]
  76. Get:10 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 distro-info-data all 0.43ubuntu1.8 [4,664 B]
  77. Get:11 http://mirrors.aliyun.com/ubuntu focal-updates/main amd64 tzdata all 2021a-2ubuntu0.20.04 [297 kB]
  78. Fetched 6,999 kB in 13s (550 kB/s)
  79. Preconfiguring packages ...
  80. (Reading database ... 76022 files and directories currently installed.)
  81. Preparing to unpack .../libpam0g_1.3.1-5ubuntu4.3_amd64.deb ...
  82. Unpacking libpam0g:amd64 (1.3.1-5ubuntu4.3) over (1.3.1-5ubuntu4.2) ...
  83. Setting up libpam0g:amd64 (1.3.1-5ubuntu4.3) ...
  84. (Reading database ... 76022 files and directories currently installed.)
  85. Preparing to unpack .../libpam-modules-bin_1.3.1-5ubuntu4.3_amd64.deb ...
  86. Unpacking libpam-modules-bin (1.3.1-5ubuntu4.3) over (1.3.1-5ubuntu4.2) ...
  87. Setting up libpam-modules-bin (1.3.1-5ubuntu4.3) ...
  88. (Reading database ... 76022 files and directories currently installed.)
  89. Preparing to unpack .../libpam-modules_1.3.1-5ubuntu4.3_amd64.deb ...
  90. Unpacking libpam-modules:amd64 (1.3.1-5ubuntu4.3) over (1.3.1-5ubuntu4.2) ...
  91. Setting up libpam-modules:amd64 (1.3.1-5ubuntu4.3) ...
  92. (Reading database ... 76022 files and directories currently installed.)
  93. Preparing to unpack .../0-libpython3.8_3.8.10-0ubuntu1~20.04.1_amd64.deb ...
  94. Unpacking libpython3.8:amd64 (3.8.10-0ubuntu1~20.04.1) over (3.8.10-0ubuntu1~20.04) ...
  95. Preparing to unpack .../1-python3.8_3.8.10-0ubuntu1~20.04.1_amd64.deb ...
  96. Unpacking python3.8 (3.8.10-0ubuntu1~20.04.1) over (3.8.10-0ubuntu1~20.04) ...
  97. Preparing to unpack .../2-libpython3.8-stdlib_3.8.10-0ubuntu1~20.04.1_amd64.deb ...
  98. Unpacking libpython3.8-stdlib:amd64 (3.8.10-0ubuntu1~20.04.1) over (3.8.10-0ubuntu1~20.04) ...
  99. Preparing to unpack .../3-python3.8-minimal_3.8.10-0ubuntu1~20.04.1_amd64.deb ...
  100. Unpacking python3.8-minimal (3.8.10-0ubuntu1~20.04.1) over (3.8.10-0ubuntu1~20.04) ...
  101. Preparing to unpack .../4-libpython3.8-minimal_3.8.10-0ubuntu1~20.04.1_amd64.deb ...
  102. Unpacking libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04.1) over (3.8.10-0ubuntu1~20.04) ...
  103. Preparing to unpack .../5-libpam-runtime_1.3.1-5ubuntu4.3_all.deb ...
  104. Unpacking libpam-runtime (1.3.1-5ubuntu4.3) over (1.3.1-5ubuntu4.2) ...
  105. Setting up libpam-runtime (1.3.1-5ubuntu4.3) ...
  106. (Reading database ... 76022 files and directories currently installed.)
  107. Preparing to unpack .../distro-info-data_0.43ubuntu1.8_all.deb ...
  108. Unpacking distro-info-data (0.43ubuntu1.8) over (0.43ubuntu1.6) ...
  109. Preparing to unpack .../tzdata_2021a-2ubuntu0.20.04_all.deb ...
  110. Unpacking tzdata (2021a-2ubuntu0.20.04) over (2021a-0ubuntu0.20.04) ...
  111. Setting up libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04.1) ...
  112. Setting up distro-info-data (0.43ubuntu1.8) ...
  113. Setting up tzdata (2021a-2ubuntu0.20.04) ...
  114. Current default time zone: 'Etc/UTC'
  115. Local time is now: Sat Oct 9 11:50:18 UTC 2021.
  116. Universal Time is now: Sat Oct 9 11:50:18 UTC 2021.
  117. Run 'dpkg-reconfigure tzdata' if you wish to change it.
  118. Setting up python3.8-minimal (3.8.10-0ubuntu1~20.04.1) ...
  119. Setting up libpython3.8-stdlib:amd64 (3.8.10-0ubuntu1~20.04.1) ...
  120. Setting up python3.8 (3.8.10-0ubuntu1~20.04.1) ...
  121. Setting up libpython3.8:amd64 (3.8.10-0ubuntu1~20.04.1) ...
  122. Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
  123. Processing triggers for man-db (2.9.1-1) ...
  124. Processing triggers for mime-support (3.64ubuntu1) ...
  125. webrx@us:~$

2、下载JDK17

file

linux 系统下,使用wget下载

$ wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz

file

3、解压jdk-17_linux-x64_bin.tar.gz

4、复制到/usr/local/jdk-17

file

5、配置环境变量

$ sudo vim /etc/profile

file
file
file

  1. webrx@us:~$ cat /etc/profile
  2. # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
  3. # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
  4. if [ "${PS1-}" ]; then
  5. if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
  6. # The file bash.bashrc already sets the default PS1.
  7. # PS1='\h:\w\$ '
  8. if [ -f /etc/bash.bashrc ]; then
  9. . /etc/bash.bashrc
  10. fi
  11. else
  12. if [ "`id -u`" -eq 0 ]; then
  13. PS1='# '
  14. else
  15. PS1='$ '
  16. fi
  17. fi
  18. fi
  19. if [ -d /etc/profile.d ]; then
  20. for i in /etc/profile.d/*.sh; do
  21. if [ -r $i ]; then
  22. . $i
  23. fi
  24. done
  25. unset i
  26. fi
  27. export JAVA_HOME=/usr/local/jdk-17
  28. export CLASSPATH=.:$JAVA_HOME/lib
  29. export PATH=.:$JAVA_HOME/bin:$JAVA_HOME/lib:$PATH
  30. webrx@us:~$

6、编写Demo测试一下

  1. Demo.java
  2. public class Demo{
  3. public static void main(String[] args){
  4. System.out.println("Hello World");
  5. System.out.println(System.getProperty("java.version"));
  6. System.out.println(System.getProperty("java.home"));
  7. System.out.println(System.getProperty("os.name"));
  8. }
  9. }

file
file

本文转自:https://blog.csdn.net/webrx/article/details/120678805

本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学