They are interpreted by the Java interpreter, thus running on the Java Virtual Machine.
The main Method
is the entry point of every Java application.
Every Java application must contain a main method whose signature
looks like this:
public static void main(String[] args)
Example. The HelloWorldApplication class implements an application that writes "Hello World!" to the standard output:
class HelloWorldApplication
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
The main method controls the flow of the program,
allocates whatever resources are needed, and runs any other
methods that provide the functionality for the application.
javac HelloWorldApplication.javaThe output is the file "HelloWorldApplication.class" containing the Java byte code of the application.
Then you run the application with the Java interpreter, specifying the name of the class file (without the .class extension):
java HelloWorldApplicationThe interpreter invokes the main method defined within that class.