Set up Java development environment in Macbook with Java 19 and Maven

Data Backend Tech
3 min readDec 23, 2022

--

Tools

We gonna need following tools for Java development in Mac:

  • Java SDK
  • Maven
  • Intelij Idea

Install Java 19 SDK

Download jdk-19 from Oracle website: https://www.oracle.com/java/technologies/downloads/#jdk19-mac.

For Apple M1 chip, you can download following installation package: https://download.oracle.com/java/19/latest/jdk-19_macos-aarch64_bin.dmg.

Once installation is successful, try ‘java -version’ in terminal, and you would be able to see Java information:

Install Maven for dependency management

tar xzvf apache-maven-3.8.6-bin.tar.gz
  • Then add the bin directory of the created directory apache-maven-3.8.6 to the PATH environment variable by using following command. Don’t forget to update the path to the correct path in the command.
export PATH=/SOME_PATH_TO_MAVEN/apache-maven-3.8.6/bin:$PATH
  • You can put the above command in either ~/.bashrc for bash shell or ~/.zhrc for zsh shell, so that the PATH will get updated automatically every time you login to the system.
  • Then run ‘mvn -v’ in the terminal, you would be able to see the mvn information:
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /SOME_PATH_TO_MAVEN/apache-maven-3.8.6
Java version: 19.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "11.6", arch: "aarch64", family: "mac"

Get sample Java project with Spring Boot

Install Intelij Idea as the Java IDE

  • Open the Maven window and click ‘refresh’ button, so that Intelij Idea will download all dependencies mentioned in pom.xml
  • Then we can click the ‘run’ button, the DemoApplication will be built and run
  • console output would be like:

Summary

In this article, we explained how to set up Java development environment in Mac. Happy coding!

References:

--

--