Installing Java and VS Code

This module illustrates how to install the core tools and workflow used throughout CS 231: Java, the command line, and Visual Studio Code.

Complete each task in order. Ask questions as you go.

Task 1: Install Java

  1. Visit adoptium.net
  2. Your operating system and chip architecture should be detected automatically
  3. Confirm that the current version is Java 25
  4. Download the installer
  5. Open your Downloads folder and run the installer

Notes:

Verify the installation:

  1. Open a terminal
  2. Type the following command:
java -version

You should see output similar to:

javac 25.0.1

Task 2: Install Visual Studio Code

  1. Visit code.visualstudio.com
  2. Download and install VS Code for your operating system
  3. Launch VS Code once installation is complete

We will configure VS Code further in later labs. For now, a default installation is sufficient.

Task 3: Write your first Java program

  1. Create a new folder on your desktop named Lab1
  2. Open VS Code
  3. Drag the Lab1 folder onto the VS Code window
  4. Create a new file named Lab1.java

Create a public class whose name matches the file name:

public class Lab1 {

}

Add the program entry point:

public static void main(String[] args) {

}

Add a print statement:

System.out.println("Hello, World!");

Compile and run your program:

  1. Open the terminal in VS Code (cmd/ctrl + j)
  2. List files:
ls

You should see:

Lab1.java
  1. Compile the program:
javac Lab1.java

List files again:

ls

You should now see:

Lab1.class
Lab1.java

Run the program:

java Lab1

You should see:

Hello, World!

Congratulations! You have written, compiled, and executed your first Java program. Don't worry if not all the syntax makes sense right now. It will be second nature in a couple of days.