Open Safari or your preferred browser
Go to the Oracle Java downloads page or install OpenJDK using Homebrew
Download the macOS installer or package for the Java version you want
Open the downloaded file
Follow the installation prompts
Enter your Mac password if asked
Wait for the installation to finish
Open Terminal
Run `java -version` to verify the installation
Run `javac -version` to verify the Java compiler
If needed, set `JAVA_HOME` in your shell profile
Restart Terminal or your Mac if required
