Easy installation of jdk on mac and configuration of environment variables

1. Installation
1. Download jdk: https://www.oracle.com/cn/java/technologies/javase-downloads.html
Insert image description here
Insert image description here
2. Install jdk: Foolish installation
Insert image description here
Insert image description here
The above installation is completed.

2. Configure environment variables
1. Find the jdk installation path:
1) Open Finder and follow the following path to find the jdk installation path;
Insert image description here
2) The Home folder under Contents is the root directory of the JDK.
Insert image description here
My computer installation path is: /Library/Java /JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home
3) Open the terminal method:
First method:
Right-click on the Home folder - Services - Create a new terminal window located in the folder location.
Insert image description here
Second type:
directly open the terminal and type:
cd /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home and press Enter;
Insert image description here
editing method one:
enter the sudo -i vi /etc/.bash_profile command and return Car;
Insert image description here
Editing method two:
create a new file: enter the touch .bash_profile command and press Enter;
Insert image description here
open the file .bash_profile: enter open -e .bash_profile and press Enter;
Insert image description here

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home/
CLASSPAHT=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH:
export JAVA_HOME
export CLASSPATH
export PATH

Then, close the window, enter the command source .bash_profile, and press Enter to make the edited content take effect; for
final verification, enter the command: echo $JAVA_HOME, and press Enter to display the configured path.
Insert image description here

Guess you like

Origin blog.csdn.net/bigge_L/article/details/108392239