There are two ways to install Java JDK and Maven on mac os:
- Download and install files from the official website
- Install using homebrew package manager
In this tutorial, we will show you how to install Java JDK and Maven on Mac os.
Download and install files from the official website
1. Install Java JDK
1） Download the JDK installation package from the website
JDK version, currently the most used JDK version is 8, so here I also choose jdk 1.8.
Then according to the operating system used, download the corresponding JDK, I am using mac, so I choose the max os version.
After the download is complete, install it.
2) Open the terminal, type
java -version to check whether the installation is successful, if the version information is output, the installation is successful.
2. Install Maven
1) download maven
I chose Apache-Maven-3.6.3-bin.tar.gz
2) When the download is complete, double-click the file to unzip or use the tar command to unzip the file
3) Setting environment variables
Assuming the installation package path to
/Users/ylspirit/Downloads/apache maven -- 3.6.3
vim ~/.bash_profile on the terminal
i to start editing the file
export M2_HOME =/Users/ylspirit/Downloads/apache maven -- 3.6.3
export PATH = $PATH: $M2_HOME/bin
d. Click ESC key and enter
:wq to save the file and exit
source ~/.bash_profile in the terminal to make the file effective
:mvn -v to check whether the installation is successful. If the version information is output, the installation is successful
➜ ~ mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Install using brew package manager
- Using brew install Java JDK 8
Use Homebrew to install, the version is the latest version of OpenJDK (Java 14):
➜ ~ brew install java
For the many use cases depending on an older version (commonly Java 8), the AdoptOpenJDK project makes it possible with an extra step.
➜ ~ brew tap adoptopenjdk/openjdk
➜ ~ brew cask install adoptopenjdk8
2. Using brew install Java Maven
Use Homebrew to install Maven, the latest version is: Maven 3.6.3
We run the following command to install:
➜ ~ brew install maven
If you want to install other versions of Maven, you can search through the brew search command first:
➜ ~ brew search maven
maven ✔ maven-shell [email protected]
maven-completion [email protected] [email protected]
Then install the required version, such as [email protected]:
➜ ~ brew install [email protected]