Next: Fit it in
Up: The Empty Program
Previous: <init>
The last item that has to be present in a class file that can be run as an
application is the main method. The main method in Java must be
declared public, static and void and must have only one
parameter of type String[] containing the program arguments.
The main method is also fully described in an entry in the
methods[] table of the class file which contains the following
information:
- Access flags ACC_PUBLIC and ACC_STATIC;
- The index of the CONSTANT_Utf8_info entry in the
constant_pool[] containing the string `` main'';
- The index of the CONSTANT_Utf8_info entry in the
constant_pool[] containing the string
`` ([Ljava/lang/String;)V'', the descriptor of the main method;
- A Code attribute containing the following information:
- Maximum number of words on the operand stack is 0;
- Maximum number of locals is 1, the parameter;
- The following line of code:
- return.
mark@bottom.xs4all.nl