Hello World – First Simple Program in Java Language

In this article, you will learn how to write simple “Hello World” program using java.

Hello World Example

This is the first simple program to use java. This program will prints “Welcome to Hello World!” on the screen.

Java program requires a main method to execute. This indicates the starting of the program. In the main method, System.out.println is used to print message on the screen.

Use any text editor such as notepad, vi editor, type the below program. Save this file as HelloWorld.java.

public class HelloWorld {
	public static void main(String[] args) {
		System.out.println("Welcome to HelloWolrd!");

How to compile a Java Program

“javac” command compiles any java file. After successful compilation, a class file with “.class” extension is created with the same name as java fie.

javac HelloWorld.java

How to run Java Program

“java” is a command to execute any java class. Type HelloWorld program as below.

java HelloWorld


Welcome to HelloWolrd!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *