DEV Community

Rafli Putra
Rafli Putra

Posted on

Step-by-Step Guide: Installing Java JDK and Maven on a Mac using Homebrew

Java is a programming language that is widely used for developing applications, and Maven is a build tool that helps manage the dependencies and build process of your Java projects. In this post, I'll walk you through the process of installing the latest version of Java and Maven on a Mac using Homebrew.

Step 1: Install Homebrew

The first step is to install Homebrew. If you don't have it installed, open the terminal and enter the following command:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Step 2: Install Java

Once Homebrew is installed, you can use it to install Java. To install the latest version of Java, enter the following command in the terminal:

$ brew cask install java
$ brew cask install maven
Enter fullscreen mode Exit fullscreen mode

Step 3: Verify the Java Installation

Once the installation process is finished, ensure the installation is completed successfully with the following command:

Java:
$ java -version
Enter fullscreen mode Exit fullscreen mode

Here is an example output of successful Java installation:

openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9)
OpenJDK 64-Bit Server VM (build 15.0.1+9, mixed mode, sharing)

Maven:
$ mvn -v
Enter fullscreen mode Exit fullscreen mode

Here is an example output of successful Maven installation:

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /Users/rafliputraa/apache-maven-3.8.1
Java version: 15, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
Default locale: en_ID, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

Top comments (0)