- Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Install openjdk 17
brew install openjdk@17 - Make the JDK visiable to the system
sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk - Verify (using terminal that the correct version is installed)
java --versionjavac --version(These should so something along the lines of java version 17.0.8+0)
We're going to do a simple Hello World application in Intellij to make sure it can find the JDK you installed earlier.
- Open Intellij IDEA CE (Download and install community edition if you haven't already)
- On the Intellij launch page choose "New Project"
- Give it a cool name
- Under JDK selection, click the dropdown and find at the bottom the following selection:
/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk - Set language to Java, build system to Intellij, and make sure "Add sample code" is checked.
- Hit 'Create'
- The project will have a single .java file (src/Main.java)
- Right click on src/Main and click "Run 'Main.main()'"
- You should see Hello World print in the console if everything is set up properly.