Web Development - JDK1.8 Installation and Environment Configuration (Mac)

The first step is to download the JDK

https://www.oracle.com/java/technologies/downloads/#java8-mac

The download and installation is complete, and the default installation address of Java is: /Library/Java

The second step configures environment variables

The next step is to open the terminal (if the environment variable has been configured with .bash_profile), open the configuration file

open -e .bash_profile

⚠️If you configure environment variables for the first time, you need to create a .bash_profile file

#创建.bash_profile文件
touch .bash_profile
#然后再打开
open -e .bash_profile

Add java environment variables in the configuration file (environment variables for other languages ​​are also configured in this file!)

#可以直接用finder搜索/Library/Java查找java文件夹(即JAVA_HOME路径是你本地的,此处是我的本地路径)
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_341.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

Put the above code block into the .bash_profile file.

(If the configuration file has configured something, just continue adding code blocks at the bottom)

After saving the file, return to the terminal and enter the command "source .bash_profile" and press Enter. Make the configured .bash_profile file take effect.

#source后配置文件才会生效
source .bash_profile

#检查是否source成功  ==> 可以echo出来对应的内容就是设置成功
echo $JAVA_HOME

Guess you like

Origin blog.csdn.net/weixin_41606115/article/details/129030651