Skip to content

Share this post

paypalkofibuymeacoffeemomo

How to install OpenJDK on macOS?

Steps:

  1. Install OpenJDK using brew

    sh
    brew install openjdk
  2. Configure environment variable JAVA_HOME.

    Configure manually:

    • Add the below line to ~/.zshrc:

      export JAVA_HOME="/usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home"
    • Restart your terminal.

    Or you can run the below command:

    echo -e "\nexport JAVA_HOME=\"$(brew --prefix openjdk)/libexec/openjdk.jdk/Contents/Home\"" >> ${ZDOTDIR:-~}/.zshrc && exec zsh