-
On your laptop, create a folder for your work in this course by following these instructions.
-
Within your
s22folder, create a subfolder calledps0for the program that you are about to create. -
Launch VSCodium on your laptop.
-
In VSCodium, select the File->Open Folder menu option, and use the resulting dialog box to find and open the
ps0folder that you created in step 2. The name of the folder should appear in a new Explorer pane on the left-hand side of the VSCodium window. -
Select File->New Text File, which will open up an empty window known as an editor window for your new program. It will initially have a name that is something like Untitled-1.
-
Select File->Save, and give the file the following name:
HelloWorld.javaImportant: When naming a Java file, the case of the letters matters. Make sure to use the exact combination of upper-case and lower-case letters that we have specified.
-
Copy and paste the following code into the editor window for
HelloWorld.java:public class HelloWorld { public static void main(String[] args) { System.out.println("hello, world!"); } } -
Save the file again by selecting File->Save or using Ctrl-S.
-
Open VSCodium’s built-in Terminal pane. You can do this by pressing the Control key and the backtick key, or by selecting Terminal->New Terminal from the menu.
-
The Terminal should open at the bottom of the VSCodium window. It should already be in the
ps0folder. To compile your program, type the following command in the Terminal and then press Enter:javac HelloWorld.javaIf the command succeeds, you should not see any output. You should see a new file named
HelloWorld.classin the Explorer pane. -
To run your program, type the following command in the Terminal and then press Enter:
java HelloWorldYou should see the following output:
hello, world!Important: When using the
javacommand, use the class nameHelloWorld, not the file nameHelloWorld.java. Java class names are case-sensitive, so the capitalization must match exactly.
If you encounter any problems in getting the program to run, please
let us know by posting a question on Ed Discussion or emailing
cscie22-staff@lists.fas.harvard.edu