Simple Java Program Example

To compile and execute java programs you need JDK.JDK contains set of libraries and tools for program execution.

Following Steps needed to execute java program.

  • Download and Install JDK.Download JDK here.
  • Set Path variable for jdk/bin
  • Write Java program using Java IDE like Eclipse or can be written on notepad.
  • Compile Java program by javac className.java.
  • Run java program by java className

HelloWorld.java

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

To compile this program
javac HelloWorld.java

To execute this program

java HelloWorld

Leave a Reply