Skip to content

Installation

Installing Java

Windows (WSL) and Linux

  1. Update your package index
bash
sudo apt update && sudo apt upgrade -y
  1. Install Java 21
bash
sudo apt install openjdk-21-jdk
  1. Verify Java (you might need to restart your terminal first)
bash
java -version
  1. Install Maven
bash
sudo apt install maven
  1. Verify Maven (you might need to restart your terminal first)
mvn -v

Mac

  1. Install Java
bash
brew install openjdk@21
  1. Verify Java
bash
java -version
  1. Install Maven
bash
brew install maven
  1. Verify Maven
bash
mvn -v

Configuring VS Code

  1. Open VS Code

  2. Hit Ctrl + Shift + X to open the Extensions panel

  3. Search for "Extension Pack for Java" and install it

Running your first Java code

  1. Create a folder to put your code into:
bash
cd Repos
mkdir hello-java
  1. Make a file called Main.java:
bash
cd hello-java
touch Main.java
  1. Open the folder in VS Code:
bash
code .
  1. Inside Main.java, type the following code:
java
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
  1. Finally, run the file with java:
bash
java Main.java

You should see

Hello, World!

in the terminal.