Java “Hello World” with Eclipse

  1. Open Eclipse

    • Launch Eclipse IDE.
  2. Create a New Java Project

    • Go to File > New > Java Project.
    • Enter a project name (e.g., HelloWorld) and click Finish.
  3. Create a Java Class

    • Right-click on the src folder inside your project.
    • Select New > Class.
    • Enter HelloWorld as the name of the class.
    • Check the box for public static void main(String[] args) to create a main method.
    • Click Finish.
  4. Write the “Hello World” Code

    • Inside the HelloWorld class, replace the default code with:
        public class HelloWorld {
          public static void main(String[] args) {
              System.out.println("Hello, World!");
          }
      }
      
  5. Save the File

    • Press Ctrl + S (Cmd + S on macOS) to save the file.
  6. Run the Java Program

    • Right-click anywhere inside the main method.
    • Select Run As > Java Application.
  7. View Output

    • You should see Hello, World! printed in the Console tab at the bottom of Eclipse.

Java “Hello World” with IntelliJ IDEA

  1. Open IntelliJ IDEA

    • Launch IntelliJ IDEA IDE.
  2. Create a New Project

    • Click on Create New Project or File > New > Project.
    • Select Java on the left pane and click Next.
    • Enter a project name (e.g., HelloWorld) and click Finish.
  3. Create a New Java Class

    • Right-click on the src folder inside your project.
    • Select New > Java Class.
    • Enter HelloWorld as the name of the class and click OK.
  4. Write the “Hello World” Code

    • Inside the HelloWorld class, replace the default code with:
      public class HelloWorld {
        public static void     s main(String[] args) {
            System.out.println("Hello, World!");
        }
    }
      
  5. Save the File

    • Press Ctrl + S (Cmd + S on macOS) to save the file.
  6. Run the Java Program

    • Right-click anywhere inside the main method.
    • Select Run 'HelloWorld.main()'.
  7. View Output

    • You should see Hello, World! printed in the Run tab at the bottom of IntelliJ IDEA.

Hello World with VS Code

  1. Install the Extension Pack for Java from Microsoft.
  2. Open a folder and create HelloWorld.java.
  3. Click Run above the main method or press F5.
  4. Output appears in the integrated terminal.

VS Code auto-detects the JDK from JAVA_HOME or prompts you to install one.

Hello World from the Command Line

Without an IDE:

  mkdir hello && cd hello
echo 'public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}' > HelloWorld.java

javac HelloWorld.java
java HelloWorld
  

Single-File Source-Code Programs (Java 11+)

Run without explicit compilation:

  java HelloWorld.java
  

Useful for scripts and learning; production projects still use javac and build tools.

Troubleshooting

Error Cause Solution
cannot find symbol Typo or missing import Check spelling and imports
class HelloWorld is public, should be in file HelloWorld.java Filename mismatch Rename the file
java.lang.UnsupportedClassVersionError JDK too old Upgrade JDK or recompile

Exercise

Create the same Hello World program in all three environments: command line, VS Code, and one full IDE (Eclipse or IntelliJ). Compare the workflow and note which steps differ.