Build Your First Java Console App: A Step‑by‑Step Guide for Absolute Beginners

Ever wonder why every big program starts with a tiny “Hello, World!” printed on the screen? That simple line is the first step on a path that can lead you to building games, web services, or even AI tools. If you’re reading this, you’re ready to take that first step with Java. Let’s get your first console app up and running, no mystery, no fluff.

What You Need Before You Start

Before we write a single line of code, make sure you have three things ready:

  1. Java Development Kit (JDK) – This is the core Java engine that compiles and runs your code. Download the latest stable version from Oracle or OpenJDK.
  2. A Text Editor or IDE – If you already have an editor you like (VS Code, Sublime, Notepad++), that’s fine. Beginners often start with the free IntelliJ Community Edition because it points out mistakes as you type.
  3. A Command Prompt or Terminal – We’ll run the program from the command line, so you need a place to type commands. On Windows, open “cmd”; on macOS or Linux, open “Terminal”.

That’s it. No fancy frameworks, no Docker containers. Just plain Java.

Setting Up Your Development Environment

1. Install the JDK

  • Run the installer you downloaded.
  • During installation, make sure the option “Add to PATH” is checked. This lets you call java and javac from any folder.

To verify, open a command prompt and type:

java -version

You should see something like java version "17.0.2" – that means Java is ready.

2. Choose a Folder for Your Project

Create a new folder where you’ll keep the files. For example:

mkdir C:\JavaJumpstart\FirstApp   (Windows)
mkdir ~/JavaJumpstart/FirstApp    (macOS/Linux)

Navigate into it:

cd C:\JavaJumpstart\FirstApp

3. Open Your Editor

Open the folder in your editor. In VS Code you can type code . from the terminal, and the whole folder will appear in the sidebar.

Writing Your First Java Program

Now the fun part. Inside the folder, create a new file named Main.java. The name matters: the file must end with .java and the class inside must match the file name.

Paste the following code:

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

Let’s break it down:

  • public class Main – Declares a class called Main. In Java, every program lives inside a class.
  • public static void main(String[] args) – This line defines the entry point. When you run the program, the Java runtime looks for this exact method signature.
  • System.out.println(...) – Sends text to the console, followed by a new line. Think of it as “print this message”.

Save the file. If you’re using an IDE, you’ll see a green play button appear next to the class name. That’s a nice shortcut, but we’ll also learn how to run it from the command line.

Running the Program from the Command Line

1. Compile the Code

In the terminal, type:

javac Main.java

javac stands for Java Compiler. If everything is correct, this command creates a new file called Main.class. That file contains the byte‑code the Java Virtual Machine (JVM) understands.

If you see an error, double‑check the spelling of Main.java and make sure the public class name matches the file name.

2. Execute the Program

Now run:

java Main

You should see:

Hello, Java Jumpstart!

Congratulations! You just compiled and ran your first Java console app.

Common Mistakes and How to Fix Them

  • File name and class name don’t match – Java is strict about this. If your file is Main.java, the class must be public class Main. Rename one or the other to fix it.
  • Forgot to add public static void main – Without this exact method, the JVM won’t know where to start. Copy the line exactly as shown.
  • PATH not set – If javac or java commands are not recognized, reinstall the JDK and ensure the “Add to PATH” option is checked, or manually add the JDK’s bin folder to your system’s PATH variable.
  • Using the wrong folder – Make sure you are in the same directory as Main.java when you run javac. Use dir (Windows) or ls (macOS/Linux) to list files and confirm.

Next Steps

Now that you have a working console app, you can start experimenting:

  1. Read user input – Use Scanner to ask the user for their name and greet them personally.
  2. Add a loop – Print numbers from 1 to 10 using a for loop.
  3. Create another class – Split your code into multiple files to see how Java organizes larger projects.

Each small experiment builds confidence and introduces new concepts without overwhelming you. Remember, the goal isn’t to write a massive program right away; it’s to understand how Java pieces fit together.

When you feel ready, check out the next tutorial on Java Jumpstart where we dive into variables, data types, and simple arithmetic. The journey from “Hello, World!” to a full‑featured app is just a series of tiny steps, and you’ve just taken the first one.

Reactions