Visit: https://brew.sh/
Run in terminal: brew install java
Run in terminal: java -version
Visit: https://www.oracle.com/java/technologies/downloads/
- Check Java path:
ls /Library/Java/JavaVirtualMachines/
- Export JAVA_HOME as a system variable:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home
- Check the path in
.zshrcand add the following if it was not added properly:export JAVA_HOME=$(/usr/libexec/java_home)
- Create a
.javafile in Visual Studio Code inside your project to be recognized by the Java extension. - Install the Java Extension Pack for Java (recommended by Visual Studio Code).
- Create packages as holders for Java files:
- Right-click on the Java projects (bottom left options) / in the project folder, select "New Package."
- Name it in the VS Code palette.
- The name should be in lower case by convention.
- Create Java files inside your packages (names should start with a capital letter).
- Package: Holds Java files.
- Main method: The default method in a class and will be the first to be executed.