JDK安装配置
一、Windows
二、Linux
1、下载jdk压缩包
wget https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.tar.gz
2、解压
tar -xvf jdk-19_linux-x64_bin.tar.gz
3、配置环境变量
①:vim ~/.bashrc
②:在末尾添加以下内容(路径注意修改)
export JAVA_HOME=/path/to/jdk-19.0.1
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
③:环境变量生效
source ~/.bashrc
三、Mac
1.下载JDK :https://www.oracle.com/java/technologies/downloads/#java8-mac
2.安装
3.配置环境变量
1)找到JDK,路径为:/Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home
2)打开终端,在home下创建一个 .bash_profile的隐藏配置文件 touch .bash_profile
3)open -e .bash_profile 打开配置文件
4)配置如下内容:
# JDK JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home PATH=$JAVA_HOME/bin:$PATH:. CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:. export JAVA_HOME export PATH export CLASSPATH
5)保存,然后在终端输入 source .bash_profile使配置文件生效
6)验证环境变量是否配置成功
yangyongjie@MacBook-Air-of-Yang ~ % echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home yangyongjie@MacBook-Air-of-Yang ~ % yangyongjie@MacBook-Air-of-Yang ~ % java -version java version "1.8.0_321" Java(TM) SE Runtime Environment (build 1.8.0_321-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
查看JDK安装路径:java -verbose
homebrew 安装openjdk:
END.