Erase M1 Mac and Reinstall for Java Development


Erase your Mac

  1. Choose Apple menu  > System Settings, then click General  in the sidebar. (You may need to scroll down.)
  2. Click Transfer or Reset on the right, then click Erase All Contents and Settings.
  3. In Erase Assistant, enter your administrator information and click Unlock.
  4. Review items that will be removed in addition to your content and settings.If your Mac has multiple user accounts, click the arrow next to your account name to review the items.
  5. Click Continue, then follow the onscreen instructions.

Initial Setup

Install Xcode Command Line Tools

xcode-select --install

Install Home Brew

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

Note:

This creates the root directory /opt

This installs the following:

  • /opt/homebrew/bin/brew
  • /opt/homebrew/share/doc/homebrew
  • /opt/homebrew/share/man/man1/brew.1
  • /opt/homebrew/share/zsh/site-functions/_brew
  • /opt/homebrew/etc/bash_completion.d/brew
  • /opt/homebrew

This creates the following new directories:

  • /opt/homebrew/bin
  • /opt/homebrew/etc
  • /opt/homebrew/include
  • /opt/homebrew/lib
  • /opt/homebrew/sbin
  • /opt/homebrew/share
  • /opt/homebrew/var
  • /opt/homebrew/opt
  • /opt/homebrew/share/zsh

Install Google Chrome

brew install google-chrome

Install Various Java Versions

brew install openjdk@17
brew install openjdk@11

Note

Java 8 need the x86 architecture so will not run on a M1 chip.
To get around this do the following:

brew tap homebrew/cask-versions
brew install --cask temurin8

https://formulae.brew.sh/formula/openjdk

add the following aliases to ~/.zprofile

alias java11='export JAVA_HOME=/opt/homebrew/opt/openjdk@11'
alias java17='export JAVA_HOME=/opt/homebrew/opt/openjdk@17'
alias java8='export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home'

java17

To test the java versions work

java8
javac - version

java11
javac -version

java17
javac -version

Install Maven

brew install mvn
mvn -version

Leave a comment