惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
博客园 - 三生石上(FineUI控件)
人人都是产品经理
人人都是产品经理
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
N
Netflix TechBlog - Medium
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Vercel News
Vercel News
P
Palo Alto Networks Blog
C
CERT Recently Published Vulnerability Notes
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
L
Lohrmann on Cybersecurity
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed
The Register - Security
The Register - Security
T
Threat Research - Cisco Blogs
P
Privacy & Cybersecurity Law Blog
A
Arctic Wolf
F
Fortinet All Blogs
V
Vulnerabilities – Threatpost
The Hacker News
The Hacker News
V
Visual Studio Blog
Know Your Adversary
Know Your Adversary
博客园 - Franky
C
Check Point Blog
P
Privacy International News Feed
NISL@THU
NISL@THU
T
Tenable Blog
云风的 BLOG
云风的 BLOG
T
Tailwind CSS Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
B
Blog RSS Feed
A
About on SuperTechFans
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
G
Google Developers Blog
WordPress大学
WordPress大学
T
Threatpost
Y
Y Combinator Blog
Last Week in AI
Last Week in AI
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
T
Tor Project blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Spread Privacy
Spread Privacy

博客园 - MikeLi

ssh debug in C,Java,Python Linux install idea ubuntu耳机问题 一个好的计算机学习网站 正则表达式 gitee 设置 javac编译命令 git Ubuntu安装chrome浏览器 jdk 8 文档和API列表 「转」Java开发的构建工具 netbeans11从源码构建安装教程 Maven国内镜像 Java IDE:NetBeans 如何输入EOF ubuntu截图与录屏 如何在Linux里寻找、安装和卸载软件包How to install and update software in Linux memory
Linux安装配置JDK
MikeLi · 2025-04-05 · via 博客园 - MikeLi

Linux(Ubuntu24.04)安装配置open-jdk

一、软件包自动安装配置版本

1.检查是否安装

查看Java版本号:

java -version

2.安装

$ sudo apt install openjdk-8-jdk

安装到了哪里?

readlink -f $(which java)

/usr/lib/jvm/java-8-openjdk-amd64/bin/目录

mikeli@mikeli-DELL:/usr/share/doc/openjdk-8-jdk-headless$ ll /usr/lib/jvm/java-8-openjdk-amd64/bin/
total 524
drwxr-xr-x 2 root root  4096 Apr  5 13:31 ./
drwxr-xr-x 7 root root  4096 Apr  5 13:31 ../
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 appletviewer*
-rwxr-xr-x 1 root root 14680 Jan 26 15:38 clhsdb*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 extcheck*
-rwxr-xr-x 1 root root 14680 Jan 26 15:38 hsdb*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 idlj*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jar*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jarsigner*
lrwxrwxrwx 1 root root    15 Jan 26 15:38 java -> ../jre/bin/java*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 javac*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 javadoc*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 javah*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 javap*
-rwxr-xr-x 1 root root  2806 Jan 26 15:38 java-rmi.cgi*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jcmd*
-rwxr-xr-x 1 root root 14688 Jan 26 15:38 jconsole*
-rwxr-xr-x 1 root root 14680 Jan 26 15:38 jdb*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jdeps*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jfr*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jhat*
-rwxr-xr-x 1 root root 14712 Jan 26 15:38 jinfo*
lrwxrwxrwx 1 root root    14 Jan 26 15:38 jjs -> ../jre/bin/jjs*
-rwxr-xr-x 1 root root 14712 Jan 26 15:38 jmap*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jps*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jrunscript*
-rwxr-xr-x 1 root root 14680 Jan 26 15:38 jsadebugd*
-rwxr-xr-x 1 root root 14712 Jan 26 15:38 jstack*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jstat*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 jstatd*
lrwxrwxrwx 1 root root    18 Jan 26 15:38 keytool -> ../jre/bin/keytool*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 native2ascii*
lrwxrwxrwx 1 root root    15 Jan 26 15:38 orbd -> ../jre/bin/orbd*
lrwxrwxrwx 1 root root    18 Jan 26 15:38 pack200 -> ../jre/bin/pack200*
lrwxrwxrwx 1 root root    21 Jan 26 15:38 policytool -> ../jre/bin/policytool*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 rmic*
lrwxrwxrwx 1 root root    15 Jan 26 15:38 rmid -> ../jre/bin/rmid*
lrwxrwxrwx 1 root root    22 Jan 26 15:38 rmiregistry -> ../jre/bin/rmiregistry*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 schemagen*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 serialver*
lrwxrwxrwx 1 root root    21 Jan 26 15:38 servertool -> ../jre/bin/servertool*
lrwxrwxrwx 1 root root    20 Jan 26 15:38 tnameserv -> ../jre/bin/tnameserv*
lrwxrwxrwx 1 root root    20 Jan 26 15:38 unpack200 -> ../jre/bin/unpack200*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 wsgen*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 wsimport*
-rwxr-xr-x 1 root root 14664 Jan 26 15:38 xjc*

 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/目录

mikeli@mikeli-DELL:~/code/java$ ll /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/
total 280
drwxr-xr-x 2 root root   4096 Apr  5 13:31 ./
drwxr-xr-x 5 root root   4096 Mar 24 06:54 ../
-rwxr-xr-x 1 root root  14632 Jan 26 15:38 java*
-rwxr-xr-x 1 root root  14664 Jan 26 15:38 jjs*
-rwxr-xr-x 1 root root  14664 Jan 26 15:38 keytool*
-rwxr-xr-x 1 root root  14720 Jan 26 15:38 orbd*
-rwxr-xr-x 1 root root  14664 Jan 26 15:38 pack200*
-rwxr-xr-x 1 root root  14664 Jan 26 15:38 policytool*
-rwxr-xr-x 1 root root  14664 Jan 26 15:38 rmid*
-rwxr-xr-x 1 root root  14664 Jan 26 15:38 rmiregistry*
-rwxr-xr-x 1 root root  14664 Jan 26 15:38 servertool*
-rwxr-xr-x 1 root root  14720 Jan 26 15:38 tnameserv*
-rwxr-xr-x 1 root root 111736 Jan 26 15:38 unpack200*

看来/usr/lib/jvm/java-8-openjdk-amd64是主目录

3.配置文件在哪?

配置path和classpath

Linux path :

mikeli@mikeli-DELL:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

classpath

mikeli@mikeli-DELL:~/software$ echo $CLASSPATH

临时配置(只对本窗口生效,新开窗口不生效)

path

mikeli@mikeli-DELL:~/software/netbeans_new/nbbuild/netbeans/bin$ export PATH="/home/mikeli/software/netbeans_new/nbbuild/netbeans/bin:$PATH"
mikeli@mikeli-DELL:~/software/netbeans_new/nbbuild/netbeans/bin$ echo $PATH
/home/mikeli/software/netbeans_new/nbbuild/netbeans/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

 classpath

mikeli@mikeli-DELL:~$ export CLASSPATH="/home/mikeli/software/guava-28.0-jre.jar:$CLASSPATH"
mikeli@mikeli-DELL:~$ echo $CLASSPATH
/home/mikeli/software/guava-28.0-jre.jar:

 永久生效

For bash, edit the startup file (~/.bashrc):

mikeli@mikeli-DELL:~/software$ vim ~/.bashrc 

path:在.bashrc文件中加上

PATH=/home/mikeli/software/netbeans_new/nbbuild/netbeans/bin:$PATH
export PATH

classpath:在.bashrc文件中加上

CLASSPATH=/home/mikeli/software/guava-28.0-jre.jar:$CLASSPATH
export CLASSPATH

 使配置生效

mikeli@mikeli-DELL:~/software$ source /etc/profile

 (新开窗口)环境变量设置生效

#要新打开一个窗口
mikeli@mikeli-DELL:~/software$ echo $PATH
/home/mikeli/software/netbeans_new/nbbuild/netbeans/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
#要新打开一个窗口
mikeli@mikeli-DELL:~/software$ echo $CLASSPATH
/home/mikeli/software/guava-28.0-jre.jar:

参考文档

PATH and CLASSPATH (The Java™ Tutorials > Essential Java Classes > The Platform Environment)

Setting the Class Path

 What is a classpath and how do I set it?

 Linux进阶之环境变量文件/etc/profile、/etc/bashrc、/etc/environment

二、下载文件自行解压配置版本

三、源代码本地编译版本