How to create a Java source file?

/*

 This is a simple Java program. Call this file "Main.java". 

 */

 

public class Main {

  // Your program begins with a call to main().

  public static void main(String args[]) {

    System.out.println("Java.");

  }

}

 

In Java, a source file is called a compilation unit. It is a text file that contains one or more class definitions. The Java compiler requires that a source file use the .java filename extension.

 

In Java, all code must reside inside a class. By convention, the name of the public class should match the its file name. And Java is case-sensitive.