Example.java
public class Example{
public static void main(String[] args) {
System.out.println("My First Simple Java Program");
}
}
Explanation
- The first thing that you must learn about Java is that the name you give to the source file is very important.
- The file that holds the source code to a program is called a source file or compilation unit.
- You should also make sure the file name matches the class name
Compiling the Java program
Open a command window and execute the following command
C:\> javac Example.java
The Java compiler creates a file Example.class that contains the bytecode program your program that contains the instruction the Java Virtual Machine will execute.
Launch the Java application by execute following command:
C:\> it java Example
Output:
My First Simple Java Program |