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

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

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

8条回答
  •  迷失自我
    2020-11-30 10:07

    No, I don't think so. main() is the entry point. That's defined by the language. You can wrap a script around the main() call ("java MyApp arg1...argn"), of course, to obscure the name (and even hide that you're using Java) and to provide your own parameter syntax and parsing -- that is a capability provided by the OS, of course, through some sort of command-line scripting language.

    If you use Java to create other types of executables, like Applets or GWT applications, then the entry point is different, but I think you're thinking specifically about executables run from the command line.

提交回复
热议问题