目录
JDK
简介
JDK:java development kit (java开发工具)
JDK / JRE / JVM 区别
- JRE:java runtime environment (java运行时环境)
- JVM:java virtuak machine (java虚拟机)
- 一般来讲
- JDK 会包含 JRE 和 JVM
- JRE 会包含 JVM
环境
- ubuntu - 20.04
- Win11
- JDK - 17.0.2
官网下载
- https://www.oracle.com/java/
- 如图即可找到jdk的下载
![](https://blog.coolight.cool/wp-content/uploads/2022/03/image-9-1024x498.png)
- linux系统
- 后缀为tar.gz的下载后上传到linux(建议使用WinSCP),然后解压
- linux解压tar.gz命令:tar -zxvf 压缩包名.tar.gz
- 其他类型的根据对应系统的安装命令执行即可
- linux的JAVA环境变量配置
- 后缀为tar.gz的下载后上传到linux(建议使用WinSCP),然后解压
![](https://blog.coolight.cool/wp-content/uploads/2022/03/image-10-1024x498.png)
- Win
- 后缀为zip的压缩包下载后需要同Linux的tar.gz类型的操作一致(见本文的上文)
- 后缀是exe的就是有图形界面的安装程序,新手可以用这个,安装比较简单
- 像我的习惯是在win也使用zip压缩包,因为这个在同时安装多个java版本时,配置环境变量挺简单的,安装程序的环境变量配置没试过。
- 如果你使用的是压缩包,则需要:win的JAVA环境变量配置
- 如果你使用的是安装程序,则跟着安装程序走就可以了。
![](https://blog.coolight.cool/wp-content/uploads/2022/03/image-11-1024x236.png)
配置环境变量
当我们在cmd命令行敲命令时,cmd如何知道这个命令对应的可执行文件在哪里?这就要配置环境变量来告诉cmd去哪里找。当然环境变量还有其他用途,比如我们下面配置的CLASSPATH就关系到javac的编译。
Linux
- 修改配置文件 /etc/profile
- # vi /etc/profile
- 然后按大写的 G,就会跳到文件末尾
- 按 i,进入编辑模式
- 配置JAVA_HOME
- 输入:
- JAVA_HOME = 刚刚解压的java文件夹目录
- 比如:JAVA_HOME=/home/0Acoolight/java/jdk-17.0.1
- 注意:这个java路径的下一级就包含bin,conf等目录和文件,千万不能搞错了。
- 配置这个可以让你在cmd的任意目录下都可以执行 java / javac 命令。
- 比如:java -version ;javac -version 等。
- 输入:
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-23.png)
- 配置CLASSPATH
- 这个是固定的,你也可以在这里加附加的jar包,新手复制下面的内容进去就可以了。
- CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib
- 配置这个是给 javac 编译时用的。
- 配置PATH
- 直接复制进去即可
- PATH=$JAVA_HOME/bin:$PATH
- 最后设置PATH生效:
- export PATH
- 完成后就是这个样子:
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-8.png)
- 保存退出
- 按英文的冒号 :
- 输入wq,然后回车即可保存退出vi并回到cmd。
- 令配置文件生效:
- # source /etc/profile
- 测试是否成功
Win
- 按 win + i 打开设置
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-10.png)
- 点 高级系统设置
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-11.png)
- 点 环境变量
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-12.png)
- 点 新建
- 输入变量名:JAVA_HOME
- 输入变量值:刚刚的java压缩包解压后的目录
- 注意:这个变量值的目录的下一级就包含着bin conf等目录,千万不能错
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-15-1024x577.png)
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-14.png)
- 再点一次新建:
- 输入变量名:CLASSPATH
- 输入变量值:.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
- 强烈建议复制进去,注意变量值的最前面,是有一个英文的句号 . 和分号 ;
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-16.png)
- 修改Path
- 在系统变量里找变量名为 Path 的那一行
- 选中它,然后点编辑
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-17.png)
- 点 新建
- 输入 %JAVA_HOME%\bin
- 点上移,直到刚刚新建的那一行到第一行
- 最后点确定即可
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-18.png)
- 至此环境变量配置就完成了
- 测试是否成功:
- 如果你已经打开cmd,请关掉重开或者重新开一个,然后进行下面的测试。
测试是否成功
- 在cmd输入 java -version,然后回车
- 在cmd输入 javac -version,然后回车
- 如果配置成功,效果如图:
- 由于你的java版本号不一定和我一样,所以只要提示信息不是报错就行。
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-9.png)
多个JAVA版本的配置
由于有些软件对JAVA版本有要求,所以可以会要安装多个JAVA版本。
- 思路:
- 还记得我们之前配置的环境变量 JAVA_HOME 吗
- 我们只需要搞一个多个中间变量去指向各自的java版本的路径,然后想启动哪个版本就让JAVA_HOME指向哪个中间环境变量即可。
- 实践:
win环境:
- 比如我同时安装了 JAVA8 和 JAVA17:
- 那么就先新建两个中间环境变量:JAVA8_HOME 和 JAVA17_HOME ,并输入对应的JAVA所在路径。
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-19.png)
- 然后修改环境变量:JAVA_HOME
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-20.png)
- 比如我现在想要使用JAVA17,那就把JAVA_HOME的变量值改为 %JAVA17_HOME%
- 如果我又想用回JAVA8,则把JAVA_HOME的变量值改为 %JAVA8_HOME%
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-21.png)
- 到这里就完成了,打开cmd,输入:java -verison 查看java版本
linux环境
- linux和win基本一致,不过要注意:
- 变量值引用变量时,win下写%JAVA17_HOME%,linux要写$JAVA17_HOME
- 路径分隔在win下是分号 ; ,在linux是冒号 :
- 路径在win下是反斜杠 \ ,在linux是斜杠 /
- 保存并退出vi后,在cmd执行命令让配置文件生效:
- # source /etc/profile
- 如图是使用JAVA17。如果想使用JAVA8:
- 把 JAVA_HOME=$JAVA17_HOME
- 改为JAVA_HOME=$JAVA8_HOME
![](https://blog.coolight.cool/wp-content/uploads/2022/04/image-22.png)
mexican pharmacy mexican rx online mexican rx online
mexican online pharmacies prescription drugs: mexican mail order pharmacies – mexican border pharmacies shipping to usa
buying prescription drugs in mexico online: buying from online mexican pharmacy – medication from mexico pharmacy
http://mexicandeliverypharma.com/# best online pharmacies in mexico
purple pharmacy mexico price list: reputable mexican pharmacies online – reputable mexican pharmacies online
pharmacies in mexico that ship to usa: mexican border pharmacies shipping to usa – buying prescription drugs in mexico
http://mexicandeliverypharma.com/# reputable mexican pharmacies online
п»їbest mexican online pharmacies: п»їbest mexican online pharmacies – mexican border pharmacies shipping to usa
mexican mail order pharmacies: buying prescription drugs in mexico online – buying from online mexican pharmacy
best online pharmacies in mexico mexico pharmacies prescription drugs mexican pharmaceuticals online
https://mexicandeliverypharma.online/# mexican rx online
generic doxycycline 3626: doxycycline singapore – purchase doxycycline without prescription
paxlovid india: paxlovid covid – Paxlovid over the counter
buy cipro without rx: п»їcipro generic – buy cipro online without prescription
Paxlovid buy online: paxlovid pill – paxlovid cost without insurance
where can i buy doxycycline without prescription: doxycycline without prescription – doxycycline 400 mg brand name
п»їcipro generic: buy ciprofloxacin – antibiotics cipro
clomid for sale: buying cheap clomid without insurance – get cheap clomid without dr prescription
amoxacillian without a percription: amoxicillin script – buy amoxicillin 500mg usa
buy generic clomid no prescription: can i get cheap clomid tablets – can you get cheap clomid no prescription
can i buy doxycycline in india: doxycycline hydrochloride – doxycycline cost india
paxlovid pharmacy: paxlovid price – Paxlovid over the counter
http://doxycyclinedelivery.pro/# doxycycline prescription cost
https://doxycyclinedelivery.pro/# doxycycline 100mg otc
https://paxloviddelivery.pro/# paxlovid cost without insurance
http://doxycyclinedelivery.pro/# doxycycline otc uk
doxycycline 75 mg cost: discount doxycycline – doxycycline 100mg capsules price
Paxlovid buy online: п»їpaxlovid – Paxlovid buy online
http://ciprodelivery.pro/# where can i buy cipro online
http://paxloviddelivery.pro/# paxlovid price
paxlovid generic: Paxlovid over the counter – paxlovid price
cipro online no prescription in the usa: ciprofloxacin generic price – buy cipro without rx
https://doxycyclinedelivery.pro/# doxycycline price mexico
http://doxycyclinedelivery.pro/# cost of doxycycline
https://ciprodelivery.pro/# buy cipro online canada
order amoxicillin online no prescription: can you buy amoxicillin uk – buy amoxicillin online no prescription
https://paxloviddelivery.pro/# Paxlovid over the counter
https://clomiddelivery.pro/# where can i get cheap clomid without prescription
paxlovid price: Paxlovid buy online – paxlovid india
get cheap clomid without insurance: how can i get cheap clomid for sale – can i buy cheap clomid without dr prescription
https://clomiddelivery.pro/# generic clomid without a prescription
https://clomiddelivery.pro/# where to buy cheap clomid
can i order cheap clomid for sale: cheap clomid for sale – buying generic clomid without insurance
http://clomiddelivery.pro/# can i buy generic clomid now
http://ciprodelivery.pro/# cipro pharmacy
buy cipro without rx: antibiotics cipro – buy cipro online canada
http://ciprodelivery.pro/# where can i buy cipro online
https://ciprodelivery.pro/# cipro
can you get cheap clomid without insurance: where can i get clomid pill – how to buy cheap clomid now
https://ciprodelivery.pro/# cipro pharmacy