Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Created October 6, 2022 14:39
Show Gist options
  • Save xeoncross/90ef99b4a02cbeeaaccae1f5424e7e52 to your computer and use it in GitHub Desktop.
Save xeoncross/90ef99b4a02cbeeaaccae1f5424e7e52 to your computer and use it in GitHub Desktop.
Install Java on mac
# Using homebrew
brew install java
>>>
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
openjdk is keg-only, which means it was not symlinked into /usr/local,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.
If you need to have openjdk first in your PATH, run:
echo 'export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk you may need to set:
export CPPFLAGS="-I/usr/local/opt/openjdk/include"
>>>
After symlinking (above)
$ java -version
openjdk version "19" 2022-09-20
OpenJDK Runtime Environment Homebrew (build 19)
OpenJDK 64-Bit Server VM Homebrew (build 19, mixed mode, sharing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment