Programming Blog

Jeremy Morgan

Mostly Coherent Ramblings of a Silicon Forest Software Developer

Java Tutorial: Hello World

Author: Jeremy Morgan

The “hello world” app is always the first thing most students do in any language. Java is no different, and I’ll show you how easy it is here.

Java Tutorial - Hello World

This tutorial makes a few assumptions. We’ve assumed that you’ve installed the JDK and have it running. For this tutorial I’m using Ubuntu Linux at the command line, but the code is the same if you’re using Windows.

Step 1: Create File

Create a file called “”. In there type the following code:

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

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

This code is pretty self explanatory. We’re creating a class called “HelloWorld”. When that class executes the first thing that runs is the main() method. Within that method we have a System.out.println method that outputs text.

Step 2: compile

To compile this, we simply type:


This compiles into a file named HelloWorld.class

Step 3: Run

To run this file, we type in:

java HelloWorld

And it outputs text. It’s that easy!

Now find some ways to make text output interesting. There are thousands of cool things you can do at the console.

Do you like articles like this?

I’m constantly hacking on stuff and writing about happenings in the programmer world. You can subscribe to my feed here, or you can get the hacker newsletter 100% spam free!

You can also follow my projects on GitHub: