We’ll be using OpenJDK 17 as our grading environment. For maximum compatibility, please make sure you are using JDK 17 locally. However, you are free to use any IDEs you want (but you should not use any AI-assisted code completion plugins).
(For Windows, skip to the section below)
-
Check if you have the up-to-date Java installed.
Type the following command in your Terminal:
java -version
The output of the above command should give:
java version “X.X.X.X”
, where X.X.X.X specifies the version number. If your Java version is not 17.x.x.x, then you need to get the updated version. If an error gets produced saying there is “No Java runtime present”, then you have to perform a fresh installation. -
Download Java.
You may follow this guide if you can’t tell if your Mac is Intel-based or M1/M2-based.
- For Macs with Intel processors, use https://download.oracle.com/java/17/latest/jdk-17_macos-x64_bin.dmg.
- For Macs with Apple Silicon processors (M1/M2), https://download.oracle.com/java/17/latest/jdk-17_macos-aarch64_bin.dmg.
-
When you’ve finished the download, click it and follow the installer. You might also have to double click the box (shown in the first photo below) to start the installer (you can keep the default options).
-
Re-run the following command in your terminal to ensure you have the correct version.
java -version
It should now give you a version number that is 17.x.x.x.
-
Check if you have the up-to-date Java installed.
Type the following command in your Command Prompt:
java -version
The output of the above command should give:
java version X.X.X
, where X.X.X specifies the version number. If your Java version is not 17.x.x.x, then you need to get the updated version. If an error gets produced saying there is “No Java runtime present”, then you have to perform a fresh installation. -
Download Java: https://download.oracle.com/java/17/latest/jdk-17_windows-x64_bin.exe
-
When you’ve finished the download, click it and follow the installer.
-
Type
javac
in the command prompt and see the output, if you getjavac is not recognized as an internal or external command
, this means the JDK Path is not set. To set it:- Find the location of your Java folder (by default Java is installed in
C:\Program Files\Java
). Go to the Java folder, and then go into the bin folder, which is inside the Java folder (by defaultbin
can be found atC:\Program Files\Java\jdk-17.0.4.1
). In the bin folder, you should see the filesjavac.exe
andjava.exe
. Highlight the path and copy it as shown below.
-
In explorer, right-click on “This PC”, and select “Properties”.
-
Scroll down to find “Advanced System Settings”.
-
Open “Environment Variables”, select the variable named ‘Path’ and press ‘Edit’ under the ‘User Variables for xxx’ section to edit the Path environment variable.
-
Click New and paste the path (e.g.,
C:\Program Files\Java\jdk-11.0.5\bin
) to your Java bin folder. Click OK. -
Finally, open a new command prompt window again and type
javac
. You should see something like below.\> javac Usage: javac <options> <source files> where possible options include: ...
- Find the location of your Java folder (by default Java is installed in
-
Download and install VS Code (https://code.visualstudio.com). You can keep all the default options.
-
Create a new folder on your preferred location (e.g Desktop, Documents) to save our code files.
-
Open the folder you just created by clicking “File” - “Open Folder”, and then proceed to select the folder you just created.
-
Create a new file by clicking “File” - “New Text File”, and then type the following HelloWorld program in the text editor.
/** * Name: Qingyang Hu * Email: [email protected] * PID: A16164360 * This is an example Java file to demonstrate how to print * a message to standard output. */ /** * This is the class for our HelloWorld program. You may modify the message by * changing the MESSAGE variable. */ public class HelloWorld { private final static String MESSAGE = "Hello World!"; /** * This is the main method of the program, and it'll print a Hello World * message to standard output. * @param args not used in this program */ public static void main(String[] args) { System.out.println(MESSAGE); } }
-
Once you’re done typing, choose “File” then “Save” then change type to “Java” and save the file as HelloWorld.java.
-
In VS Code, click on the Explorer icon on the top left to see the files. Then right click on “HelloWorld.java”, and click on “Open in Integrated Terminal”.
-
Type the following in your Terminal to compile your code:
javac HelloWorld.java
You should not see any error messages. This will produce a file named
HelloWorld.class
, which will store information about the file you just compiled. -
Finally, to run the file, type the following (make sure you do not add the “.class” part at the end of the file name):
java HelloWorld
You should see “Hello World!” printed in your Terminal.