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

推荐订阅源

T
The Blog of Author Tim Ferriss
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
C
Cybersecurity and Infrastructure Security Agency CISA
Know Your Adversary
Know Your Adversary
C
Cyber Attacks, Cyber Crime and Cyber Security
爱范儿
爱范儿
M
MIT News - Artificial intelligence
V
Vulnerabilities – Threatpost
F
Fortinet All Blogs
月光博客
月光博客
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
Spread Privacy
Spread Privacy
P
Proofpoint News Feed
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Tor Project blog
T
Troy Hunt's Blog
Latest news
Latest news
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
N
News and Events Feed by Topic
F
Full Disclosure
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CERT Recently Published Vulnerability Notes
H
Hacker News: Front Page
C
Cisco Blogs
I
Intezer
P
Privacy International News Feed
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
Last Week in AI
Last Week in AI
Scott Helme
Scott Helme
B
Blog
博客园_首页
MyScale Blog
MyScale Blog
Cloudbric
Cloudbric

博客园 - 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

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

三、源代码本地编译版本