Can I invoke a java method other than main(String[]) from the command line?

后端 未结 8 527
夕颜
夕颜 2020-11-30 09:35

Can I invoke a java method other than main(String[]) from the command line?

8条回答
  •  温柔的废话
    2020-11-30 10:16

    From The Java Virtual Machine Specification

    The Java virtual machine starts up by creating an initial class, which is specified in an implementation-dependent manner, using the bootstrap class loader (§5.3.1). The Java virtual machine then links the initial class, initializes it, and invokes its public class method void main(String[]). The invocation of this method drives all further execution. Execution of the Java virtual machine instructions constituting the main method may cause linking (and consequently creation) of additional classes and interfaces, as well as invocation of additional methods.

    So main appears to be special.

提交回复
热议问题