Java “Hello World” for Beginners: Run Your First Program (Online IDE, JDK, IntelliJ/Eclipse)

目次

1. What Java “Hello World” Is (What You Confirm First)

1.1 Why Hello World Is the Perfect “First Step”

“Hello World,” which often appears first when learning programming, is not just an example that prints text.
When you start learning Java, running this program has a clear purpose.

With Hello World, you can confirm the following three points.

  • Whether your Java program is written in the correct form
  • Whether your runtime environment (JDK, IDE, online environment, etc.) is working properly
  • Whether you understand “where Java starts executing”

If even Hello World won’t run, you’ll definitely get stuck later when you write more complex logic.
On the other hand, if you can display Hello World, you’ve reached the starting line for Java development.

Hello World also contains the entire basic structure of Java.

  • Class (class)
  • Entry point (main method)
  • Standard output (System.out.println)

These three elements appear in every Java program you write going forward.
So taking the time to understand Hello World carefully at the beginning may look like a detour, but it’s actually the shortest route.

1.2 The Minimum Java Structure (class and main)

The most basic code to display Hello World in Java looks like this.

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

It may look difficult at first, but you don’t need to “fully understand everything” here.
For now, focus on what each part does.

Class (class)

public class Main {

In Java, the rule is that all logic must be written inside a class.
Main is the class name, and the file name is usually Main.java.

As a beginner, it’s enough to follow these two rules:

  • Class name = file name
  • Start with a letter

If you keep these, you’re good.

The main Method (Program Entry Point)

public static void main(String[] args) {

This line indicates where a Java program starts executing.
When Java launches a program, it always looks for the main method and starts processing from there.

At this stage, it’s enough to understand:

  • “Java starts from main
  • “This shape is the standard pattern”

That’s all you need for now.

Printing Text to the Screen

System.out.println("Hello World");

This is the line that actually prints text to the screen.

  • System.out.println
    → A command to output text to the screen (console)
  • "Hello World"
    → The string you want to display

When this single line runs, Hello World is displayed.

What Curly Braces { } Mean

In Java, { and } are used to group a block of code.

  • Inside a class
  • Inside a method

They define boundaries, and if the counts don’t match, you’ll get an error.
As a beginner, it helps to build the habit: “If you open one, always close it.”

2. Fastest Start: Java Hello World in Your Browser (Online IDE)

2.1 Benefits and Caveats of Using an Online IDE

When you’ve just started learning Java, trying to set up a full development environment right away can be frustrating.
People often stumble on things like “Installing the JDK” and “Setting environment variables.”

That’s why an online IDE is a great option.
It’s a service where you write Java code in the browser and run it immediately.

Key benefits of using an online IDE include:

  • No need to install anything on your PC
  • You can write and run code immediately
  • You don’t have to worry about environment setup failures

Especially if your goal is “I just want to run Hello World first,” this method is a perfect match.

However, there are some caveats:

  • Behavior may differ from a real local environment (your own PC)
  • You can’t finely control file structure or settings
  • It’s not suitable for professional, production-level development

So the ideal approach is to use it as an entry point, then move to a local environment once you’re comfortable.

2.2 Steps to Run Hello World in an Online IDE

Here, we’ll describe the general flow for running Java Hello World using a typical online IDE.
The exact UI differs by service, but the core steps are the same.

Step 1: Make Sure Java Is Selected

After opening the online IDE, first confirm that the language is set to Java.
Many services show a Java template by default.

If it’s set to another language (like Python or JavaScript), switch it to Java.

Step 2: Enter the Hello World Code

Type (or paste) the following code into the editor.

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

In many online IDEs, the class name is expected to be Main.
So it’s safest to keep the class name as Main.

Step 3: Click the Run Button

After entering the code, click a button such as “Run,” “Execute,” or “Run Code.”
If everything is correct, you’ll see output like this after a few seconds in the output panel.

Hello World

If you see this, your Java program ran successfully.

2.3 Checkpoints When You Get an Error (Online IDE)

If you see an error when running the code, check the following points.

Is the Class Name Different?

public class Main {

Many online IDEs assume the class name is Main.
If you change it to something like HelloWorld, it may cause an error.

Do the Curly Braces { } Match?

In Java, matching { and } is critical.
If you accidentally have one too many or too few when copying/typing, you’ll get a compile error.

Are Double Quotes Full-Width?

System.out.println("Hello World");

If you type while a Japanese IME mode is active,
" can become full-width, which may cause an error.

2.4 Treat an Online IDE as a “Quick Verification Tool”

Once you can display Hello World in an online IDE, your immediate goal is achieved.
What matters is the fact that “You confirmed Java runs.”

However, to learn and develop in Java for real, you need to understand:

  • How files work
  • The flow of compiling and running
  • How to read errors

So in the next section, we’ll explain how to run Java on your own PC—
specifically, the compile-and-run process using the JDK.

3. Run on Your PC: Prepare the JDK and Execute from the Command Line (The Standard Way)

Once Hello World runs in an online IDE, the next step is to run Java on your own PC.
Here, you will confirm the fundamental Java flow of compile → run using the command line.

3.1 Preparation: What Is the JDK? (A Brief Note on JRE)

To run Java on your PC, you need the JDK (Java Development Kit).

  • JDK: A complete set for developing and running Java (includes the compiler)
  • JRE: An environment only for running Java programs (now integrated into the JDK)

For beginners, it’s enough to remember:
“If you write Java, install the JDK.”

After installation, verify it with the following command.

javac -version

If a version number is displayed, the JDK is correctly recognized.

3.2 Create the Hello World Source Code

First, create the Java source file.

File Name

Main.java

Contents (Safe to Copy As-Is)

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

Important Points

  • The file name and class name must be the same
  • Uppercase and lowercase letters must also match

If you get this wrong, you’ll encounter errors later.

3.3 Compile: Create a .class File with javac

Next, open a terminal (Command Prompt or PowerShell on Windows),
and move to the folder that contains Main.java.

javac Main.java

This command:

  • Converts .java (human-written code)
  • Into .class (a format Java can execute)

This process is called compilation.

When Compilation Succeeds

No message is shown, and the following file is created in the folder.

Main.class

If no error appears, compilation succeeded.

3.4 Run: Start the Program with the java Command

After compiling, it’s time to run the program.

java Main

※ Do not include .class.

If execution succeeds, you’ll see the following output.

Hello World

This moment is proof that a Java program ran on your own PC.

3.5 Organizing the Relationship Between Compile and Run

This is a common point of confusion for beginners, so let’s summarize the flow.

  1. Create Main.java
  2. Compile with javac Main.java
  3. Main.class is generated
  4. Run with java Main

One characteristic of Java is that you don’t execute the written code directly.
This extra step enables Java’s high safety and portability.

3.6 Common Errors at This Stage

javac Not Found

'javac' is not recognized as an internal or external command

In this case, the JDK may not be installed correctly,
or the environment variable (PATH) may not be set.

Class Name and File Name Don’t Match

class Main is public, should be declared in a file named Main.java
  • The file name
  • The name of the public class

Make sure they match exactly.

4. Run with an IDE: IntelliJ IDEA / Eclipse / VS Code (Reader Options)

Running from the command line is important for understanding how Java works,
but in real-world development, it’s common to use an IDE (Integrated Development Environment).

Using an IDE provides benefits such as:

  • Automatic file creation and configuration
  • Compile and run with a single button
  • Immediate indication of errors

The more of a beginner you are, the more smoothly learning progresses when you rely on an IDE.

4.1 Benefits of Using an IDE

The biggest advantage of an IDE is that it automatically handles the troublesome parts of Java.

Specifically, an IDE takes care of tasks like:

  • Creating the project structure
  • Generating class and main method templates
  • Configuring classpaths and character encoding
  • Displaying errors and warnings in real time

This lets beginners focus purely on “writing code.”

4.2 Run Hello World with IntelliJ IDEA (Fastest Steps)

IntelliJ IDEA is currently one of the most widely used IDEs for Java.

Step 1: Create a New Project

  • Select “New Project”
  • Language: Java
  • If the JDK is not set, follow the on-screen instructions

Step 2: Create a Class with a main Method

  • Right-click the src folder
  • Select “New → Java Class”
  • Name the class Main

The IDE automatically generates code like the following.

public class Main {
    public static void main(String[] args) {

    }
}

Step 3: Add Output Code and Run

System.out.println("Hello World");
  • Click the green Run button (▶)
  • If Hello World appears at the bottom, it’s a success

4.3 Run Hello World with Eclipse (Fastest Steps)

Eclipse is also a long-established, standard IDE that has been used for Java development for many years.

Step 1: Create a Java Project

  • Select “File → New → Java Project”
  • Project name: anything you like (e.g., HelloWorld)

Step 2: Create a Class

  • Right-click src
  • Select “New → Class”
  • Class name: Main
  • Check “public static void main”

Step 3: Run

Add the following line to the generated code.

System.out.println("Hello World");
  • Right-click the class
  • Select “Run As → Java Application”
  • If output appears, you’re done

4.4 Run Hello World with VS Code (Supplement)

VS Code is a lightweight editor, but with extensions installed, it can also be used for Java development.

  • Install the Java Extension Pack
  • Prepare the JDK in advance
  • Create a main class and run it

Because setup requires a bit more configuration,
IntelliJ IDEA or Eclipse is a safer choice for complete beginners.

4.5 How to Think About Using an IDE

IDEs are extremely convenient, but it’s also important to be aware of what’s happening behind the scenes.

  • Run button = compile + run
  • Error display = results from javac

An IDE isn’t “using magic.”
It’s simply automating the command-line operations you’ve already learned.
Understanding this will make you much stronger when troubleshooting later.

5. Explaining the Code Line by Line (Key to Prevent Beginner Drop-Off)

By now, you’ve successfully run Hello World.
In this section, we’ll revisit the code you used and confirm the meaning of each line.

We’ll keep technical terms to a minimum and explain things at a level of “this understanding is enough for now.”

5.1 Class Declaration: What class Main { ... } Means

public class Main {

This line defines a container (class) for your Java program.

In Java, all processing must be written inside some class.
You cannot simply write commands on their own.

At the beginner stage, this understanding is sufficient:

  • In Java, logic is written inside a class
  • The class name must match the file name
  • The name Main is commonly used by convention

The modifier public appears here,
but for now, you can think of it as “something you add by default.”

5.2 The main Method: public static void main(String[] args)

public static void main(String[] args) {

This line represents the execution starting point of a Java program.

When Java starts a program,
it always looks for a main method with this exact form and begins processing there.

The three key points beginners should remember are:

  • Java execution starts from main
  • The syntax is fixed (memorization is fine for now)
  • Without this form, the program cannot run

Breaking it down further:

  • static: Can be called without creating an object
  • void: No return value
  • String[] args: Arguments passed at startup

But you don’t need to understand these details at the beginning.

5.3 Output Processing: System.out.println()

System.out.println("Hello World");

This line prints text to the screen.

Roughly breaking down its meaning:

  • System.out: The destination for screen output
  • println: Prints one line and then adds a newline
  • "Hello World": The string to display

This is the structure.

Difference Between print and println

  • print: Does not add a newline
  • println: Adds a newline after printing

As a beginner, using println is perfectly fine.

5.4 Meaning of Double Quotation Marks " "

"Hello World"

In Java, strings must always be enclosed in double quotation marks.

Common mistakes include:

  • Using single quotes ' '
  • Using full-width quotation marks " "

If you encounter an error,
this is often the first thing to check.

5.5 Don’t Forget the Semicolon ;

System.out.println("Hello World");

In Java, every statement must end with a ;.

Forgetting it results in a compile error.

As a beginner, it’s fine to mechanically remember:

  • “Statements end with a semicolon”

That’s enough.

5.6 Understanding the Role of Curly Braces { }

{
    processing
}

Curly braces are symbols that group a range of processing.

  • Contents of a class
  • Contents of a method

They are used to define boundaries.

Common Beginner Mistakes

  • Mismatched counts of { and }
  • Forgetting to close a brace

When using an IDE, braces are often auto-completed,
but be careful when writing code manually.

5.7 Summary of the Required Understanding at This Stage

At this point, it’s enough to understand the following:

  • Java code is written inside a class
  • The main method is the entry point
  • You can print text to the screen with println

Trying to understand everything at once is unnecessary—and avoiding that is the key to not giving up.

6. Common Errors and Solutions (Where Most Beginners Get Stuck)

Hello World is simple, but there are errors that almost every beginner encounters.
Here, we organize the most frequent ones by cause.

6.1 Class Name and File Name Don’t Match

Typical Error Example

class Main is public, should be declared in a file named Main.java

Cause

  • The file name is not Main.java
  • The public class name does not match the file name

In Java, the public class name and file name must match exactly.

Solution

  • File name: Main.java
  • Class name: public class Main

Make sure they match, including uppercase and lowercase letters.

6.2 javac / java Not Found (PATH Issue)

Typical Error Example (Windows)

'javac' is not recognized as an internal or external command

Cause

  • The JDK is not installed
  • The JDK is installed, but PATH is not set

How to Approach the Fix

  1. Run javac -version
  2. Check whether a version is displayed
  3. If not, reinstall the JDK or review PATH settings

At the beginner stage, using an IDE to avoid this issue is also a practical choice.

6.3 Garbled Text When Displaying Japanese

Example

System.out.println("こんにちは");

The output appears as something like ???.

Three Main Causes

  1. Character encoding used to save the source file
  2. Character encoding used during compilation
  3. Character encoding of the execution environment (terminal)

Basic Fix Example

javac -encoding UTF-8 Main.java

Also make sure your editor is set to UTF-8 encoding.

6.4 Could Not Find or Load Main Class

Typical Error Example

Error: Could not find or load main class Main

Cause

  • You are running the command from the wrong directory
  • You did not compile the code
  • There is a package declaration that you didn’t account for

Beginner-Friendly Fix

  • Run java Main in the directory that contains Main.class
  • Do not write a package declaration at first

6.5 Errors Are “Information,” Not “Failure”

Java error messages may look intimidating at first,
but they actually tell you very honestly what’s wrong.

  • Line numbers
  • Hints about the cause

are always included, so it’s important to
“not be afraid and get into the habit of reading them.”

7. What to Do Next (The Step After Hello World)

Once Hello World runs, you’ve cleared the Java starting line.
From here, it’s time to deepen your understanding by gradually writing code.

7.1 Modify Hello World (Mini Exercise)

First, try changing what is displayed.

System.out.println("I started Java");

Next, try displaying multiple lines.

System.out.println("Hello");
System.out.println("World");

Even with this, you can experience that:

  • Statements are executed from top to bottom
  • Processing happens line by line

These basics become clear.

7.2 Try Printing main Method Arguments

public static void main(String[] args) {
    System.out.println(args.length);
}

By passing arguments from the command line,
you can understand that Java can “receive values from outside.”

7.3 Topics to Learn Next to Broaden Your Understanding

The recommended order is:

  1. Variables and types
  2. if statements (conditional branching)
  3. for / while loops
  4. Methods
  5. Classes and objects

Hello World is not the goal—it’s the entrance.

FAQ (Frequently Asked Questions)

Q1. Should I memorize Java Hello World?

No memorization is required.
The goal is to get used to the pattern of “class,” “main,” and “println.”

Q2. Why is the main method signature so long?

Because Java is a language with strict rules.
In return, it provides a structure that runs safely even in large-scale development.

Q3. Should I use an IDE or the command line?

  • Early learning: IDE
  • Understanding how it works: command line

This division is recommended.

Q4. Hello World runs, but I don’t know what to do next

That’s normal.
Many people stop at this point.
Next, move on to “variables” and “if statements.”

Q5. Is Java a difficult language?

It feels difficult at first,
but once you build a solid foundation, it’s a very stable language.