DEV Community

Cover image for Java By Example: Hello World
Alan
Alan

Posted on

3 1

Java By Example: Hello World

Our first program will print the classic “hello world” message. Here’s the full source code.

class Helloworld {
  public static void main(String[] args) {
    System.out.println("Hello world!");
  }
}
Enter fullscreen mode Exit fullscreen mode

To run the program, we need to build our programs into Byte Code.
We can do this using javac Helloworld.java.
We can then execute the built java .class file directly.

javac Helloworld.java
ls
# Helloworld.java Helloworld.class

java Helloworld
# Hello world!
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS Security LIVE! Stream

Go beyond the firewall

Watch AWS Security LIVE! to uncover how today’s cybersecurity teams secure what matters most.

Learn More

👋 Kindness is contagious

Explore this insightful post in the vibrant DEV Community. Developers from all walks of life are invited to contribute and elevate our shared know-how.

A simple "thank you" could lift spirits—leave your kudos in the comments!

On DEV, passing on wisdom paves our way and unites us. Enjoyed this piece? A brief note of thanks to the writer goes a long way.

Okay