The goal of this exercise is to:
- create a simple Java project
- create a Java package
- create and run a simple Java program that prints
Hello World!to the screen.
-
Inside the repository root directory:
- create a sub-directory called
com - inside the
comdirectory, create a sub-directory calledcbfacademy
- create a sub-directory called
-
Inside that last sub-directory (
cbfacademy), create a file calledHelloWorld.java.
At this point, our project folder structure looks as follows:
Open the HelloWorld.java file in your code editor, type the following Java code, then save your changes.
package com.cbfacademy;
public class HelloWorld {
public static void main(String... args) {
System.out.println("Hello World!");
}
}β Compile
In your terminal, navigate to the repository root directory.
Execute this command to compile our Java program
javac com/cbfacademy/HelloWorld.javaA HelloWorld.class file is now created alongside our Java source file.
π Run
To run our Java program, let's execute the following command:
java com.cbfacademy.HelloWorldπ Our program prints the following on your screen.
Hello World!With the above, we've just created and run our first, simple, Java program.
In this exercise, we've done all the work manually to get acquainted with the basics of creating, compiling and running a simple Java program.
In the rest of the course, we'll be using Visual Studio Code to help us with the build and execution process, and focus on the Java language itself.

