Week 2 17-21-02-2025
Week 2 17-21-02-2025
Aim
The aim of this session is familiarize the student with the Java programming environment which we
are going to use in this course.
Objectives
After completing this week’s session, you should be able to:
1. Create Java source code files using a text editor such as Notepad
2. Compile Java programs from the command-line
3. Run Java programs from the command line
4. Extract and print textual input from the terminal using command-line arguments
Tasks
1. Create a folder which you are going to use for all your Java code in this course.
2. Open the Windows Command Prompt and navigate to your Java folder
Hints: You may use the command prompt $g to tidy up your prompt. Use the cls
command to clear the console.
3. In your java folder, create a text file and name it HelloWorld.java. Make sure to type the
file name exactly as it has been given, i.e., no spaces in the name, capital H in Hello and
capital W in World.
4. Copy the following code (preferably by typing, rather than copy and paste) into the
HelloWorld.java file. Make sure to copy verbatim (that is, exactly as it appears).
5. Save the file and compile your program by running the command
>javac HelloWorld.java
from the command prompt. If you are successful, a blank line will be inserted into the
console. If you made any mistakes, error messages will be displayed. Make the necessary
corrections until the program compiles.
6. Run the program using the command
>java HelloWorld
10. Compile the program and run it with the following commands
>java SimpleUserArgs
12. Describe what happen when you run the program using the command
14. Run the program with the following command and note the output.
should produce