4 ms·
brew install java export PATH="/opt/homebrew/opt/openjdk/bin:$PATH" java -version openjdk version "21.0.1" 2023-10-17
by throwitaway222 3y ago
brew install java
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
java -version
openjdk version "21.0.1" 2023-10-17
- michaelsbradley 3y agoThe instructions change a bit over time, with macOS upgrades and changes re: brew itself, but in my experience brew has a superb track record of making sure the `brew info` instructions are an exact match for what you need to do for your setup. One macOS Sonoma 14.1.1 just now: $ brew info 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"' >> /Users/[username]/.bash_profile For compilers to find openjdk you may need to set: export CPPFLAGS="-I/usr/local/opt/openjdk/include" ...