Contents

Install Java17 and maven on M1 Mac

Environment

  • MacOS Monterey 12.0, M1 Apple silicon
  • java17
  • maven 3.8.3

Install and setup java

  1. Download Arm 64 DMG Installer (.dmg package) java from Oracle site.
  2. Follow instruction by wizard
  • After install completes,

    1
    2
    3
    4
    5
    6
    
    $ java -version
    java version "17.0.1" 2021-10-19 LTS
    Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
    Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)
    $ which java
    /usr/bin/java
    
  1. Add environment variable $JAVA_HOME

    Add path to the jdk home to profile. This is necessary for configuring maven.

    ~/.bash_profile

    1
    
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home
    

    Then reload profile.

    1
    
    $ source ~/.bash_profile
    

Install and setup maven

  1. Download maven from maven.apache.org

    I selected Binary zip archive(apache-maven-3.8.3-bin.zip)

  2. unzip in any favorite command and locate it to /opt/

    1
    2
    3
    
    tar xvf apache-maven-3.8.3-bin.tar
    # apache-maven-3.8.3 directory is unzipped
    sudo mv apache-maven-3.8.3 /opt/
    
  3. Add path to “maven directory”/bin to environment variable $PATH

    ~/.bash_profile

    1
    
    export PATH=/opt/apache-maven-3.8.3/bin
    

    Then reload profile., you can confirm maven commmand.

    1
    2
    3
    4
    5
    6
    7
    8
    
    $ source ~/.bash_profile
    
    $ mvn -v
    Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
    Maven home: /opt/apache-maven-3.8.3
    Java version: 17.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home
    Default locale: en_JP, platform encoding: UTF-8
    OS name: "mac os x", version: "12.0", arch: "aarch64", family: "mac"
    

References