Lab1 Handout
Lab1 Handout
E-mail: [email protected]
In each lab session of this course we will have a similar content as follows:
A brief summary of the topics covered in the session
1-2 Group Exercise(s):
We will go over the group exercise(s) together.
You can use the group exercise(s) as a guide while solving the individual exercise(s).
1 Individual (Graded) Exercise:
You will solve the individual exercise on your own (no code sharing with other students!) and submit your
solution (a Java code file and a video in which you explain your solution) using Blackboard.
The video must contain the Java code, your voice explaining the code and your camera view while you are
explaining the code.
You can ask for help whenever needed during the lab sessions.
Grading will be done on a scale of 0: Incorrect/NA, 1: Partially correct and 2: Correct.
Important: Only the students who attend a lab session (via Zoom Meeting in Blackboard) can get a
grade for that session by solving and submitting the individual exercise given in that session.
You can attend any lab session for this course without a restriction.
This Week
Introductory Contents:
Your first Java program: Hello World
A suitable development environment for creating and running Java programs
1. Using an online Java programming environment: JDoodle IDE
2. Installing a Java programming environment in your own computer/laptop: Eclipse IDE
Using Zoom to record a video that contains a Java code, your voice explaining the code and your
camera view while you are explaining the code
Successfully submitting your Java code and video files to Blackboard
Lab 1 Contents:
Topic(s) Covered This Week
2 Group Exercises
1 Individual Exercise
You need to submit your solution (a .java code file and a video) for the individual exercise
under LAB1 in Blackboard.
Your First Java Program: Hello World
A Simple Java Program: Displaying Hello World
Each Java program must have at least one class.
Each Java program must have exactly one class containing the main method.
The main method is the entry point where the program starts execution. Thus, a Java program without a
main method cannot run.
Library Code
A Suitable Development Environment for Creating and
Running Java Programs
Using an Online Java Programming Environment
JDoodle Online Java IDE
You can use JDoodle for this lab as it has
sufficient capabilities and it is easy to use
without installing anything on your PC.
https://www.jdoodle.com/online-java-compiler/
Writing and Running the Hello World Program in JDoodle
Note: You do not need to download and install the Java Runtime Environment (JRE) as it is
included in the Eclipse Installer 2021-09 R.
Installing Eclipse IDE for Java Developers
Open the installer that you have downloaded.
After opening the installer, select “Eclipse IDE
for Java Developers” to install. Select
Installing Eclipse IDE for Java Developers
Proceed with the installation by clicking
INSTALL and follow the incoming steps in
the installer.
Click to
install
Installing Eclipse IDE for Java Developers
You will see the window on the right once
the installation is complete.
You can open Eclipse by clicking the
LAUNCH button.
Click to open
Eclipse IDE
Selecting a Folder to be used as Eclipse Workspace
After opening Eclipse you will see the window below.
Select the folder for workspace (where your programs will be stored) by using the Browse
button and then open Eclipse by clicking on the Launch button.
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Creating a Hello World Application in Eclipse:
Introduction ?
Open Eclipse. This cheat sheet shows you how to create the famous "Hello World" application and try it
Select HelpWelcome from the main menu on the top. out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
This will open the Welcome to the Eclipse IDE for Java Click to Begin
Developers window. Open the Java perspective ?
From the opened window, select Create a Hello World If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
application.
Create a Java project ?
This will open the Create a Hello World application cheat Before creating a class, we need a project to put it in. In the main toolbar, click on the
sheet which is reprinted on the right for convenience. New Java Project button. Enter HelloWorld for the project name, then click Finish.
Follow the steps in this cheat sheet as shown in the next slides to Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
create and run the Hello World application in Eclipse. Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Introduction ?
Clicking on the New Java Project button This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Introduction ?
This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
Important: Make sure that this option is not selected. ?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
After creating the project, you should see it in the
Introduction ?
Package Explorer as shown below. This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Introduction ?
Clicking on the New Java Class button This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Introduction ?
This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
No need to use packages for small programs, so leave empty. Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
Note: The class name does not have to be the same as the "Hello world!" output.
project name as in this example. Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
After creating the class, you can see it under the
Introduction ?
HelloWorld project in the Package Explorer as This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
shown below. console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
The basis for a Java program: one class containing the main method
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Introduction ?
This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Introduction ?
This cheat sheet shows you how to create the famous "Hello World" application and try it
Important: This asterisk symbol shows that the changes made on the java
out. You will create a Java project and a Java class that will print "Hello world!" in the
file are not saved. console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
The asterisk symbol disappears after clicking on the save button. ?
Introduction
This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Introduction ?
This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
right-click on the class (java file) Before creating a class, we need a project to put it in. In the main toolbar, click on the
in the Package Explorer New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Creating a Hello World Application in Eclipse IDE for Java Developers
Create a Hello World application
Introduction ?
This cheat sheet shows you how to create the famous "Hello World" application and try it
out. You will create a Java project and a Java class that will print "Hello world!" in the
console when run. If you need help at any step, click the (?) to the right. Let's get started!
Click to Begin
Open the Java perspective ?
If you're not already in the Java perspective, in the main menu select Window > Open
Perspective > Java.
Create a Java project ?
Before creating a class, we need a project to put it in. In the main toolbar, click on the
New Java Project button. Enter HelloWorld for the project name, then click Finish.
Create your HelloWorld class ?
The next step is to create a new class. In the main toolbar again, click on the New Java
Class button. If not already specified, select HelloWorld/src as the source folder. Enter
HelloWorld for the class name, select the checkbox to create the main() method, then
click Finish. The Java editor will automatically open showing your new class.
Add a print statement ?
Now that you have your HelloWorld class, in the main() method, add the following
statement:
System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.
?
Run your Java application
To run your application, right-click on your class in the Package Explorer and select Run
As > Java Application. The Console view should appear at the bottom and display the
"Hello world!" output.
Congratulations! You have successfully created a Hello World application!
Using Zoom to Record a Video Assignment
Using Zoom to Record a Video Assignment
Open the Zoom App and then you should see a window similar to the one shown below.
Using Zoom to Record a Video Assignment
Press the Settings button to open the Settings window.
Using Zoom to Record a Video Assignment
Perform the recording settings.
Set the directory in which your video will be recorded.
Using Zoom to Record a Video Assignment
A window similar to the one below will open. You can adjust the screen where your camera
view is displayed by dragging it using the mouse.
Using Zoom to Record a Video Assignment
A top panel will open when you hover your mouse over the icons at the top.
Using Zoom to Record a Video Assignment
Press the More button then press Record on this Computer from the options that open.
This starts the recording. You can now explain your code.
Using Zoom to Record a Video Assignment
Press the End button as shown below after your recording is complete. Then press the End
Meeting for All button in the window that opens.
Using Zoom to Record a Video Assignment
You will see the window below while the recorded video is being prepared.
Click Save (to local file)
Click … button to download the code
file as ClassName.java
(here HelloWorld.java)
Preparing Your Code Files for Submission (Using Eclipse IDE)
The program (code) files you submit must have the type Java having .java extension.
Do not submit compressed files (zip, rar etc.). Submit each program in a separate .java file.
How to copy your Java code file(s) from Eclipse IDE: