Tino Intro To Java

Last modified: January 07, 2023

Your First Java Program

Let's write your first Java program that prints out "Hello, world!"!

First, open BlueJ and create a new project

In the top left corner, click on Project | New Project.

The pop-up window asks for you to give a name for your new project and a folder location to save the java files. For now, just use "HelloWorld" as project name and use the default folder location.

Click OK on the pop-up windows. Now, you should have a new project named "HelloWorld" created.

Create a Java File

Click on "New Class" on the left side. Don't worry about what "class" means yet. When prompted to enter the "class name", just enter "HelloWorld" and click OK.

The above action should create a yellow box titled "HelloWorld". Click on it, which will open a separate window for you to edit the code in that file.

Delete everything in the file and put the following into it:

public class HelloWorld {
    public static void main(String[] args){
        System.out.println("Hello, world!");
    }
}

Compiling and running the program

To get your first program running:

  1. go back to the main window
  2. click on the Compile button on the left side
  3. right-click the "HelloWorld" yellow box

Click on void main(String[] args)

Then click OK on the pop-up windows without modifying any default values.

If you see the following, congratulations on creating and running your first Java program!

Dark Mode

Outline