public static void main(String arg[ ] ) in java is it fixed?

前端 未结 9 1383
离开以前
离开以前 2020-12-03 03:25

I was recently asked in an exam if public static void main(String arg[]) format of main method was fixed? Can we change it? Can we use main

9条回答
  •  囚心锁ツ
    2020-12-03 04:24

    You can change it if you create a new loader for your app. The public static void main( String args[] ) format is just the default solution people working on the JVM found to call your Java programs, so that there is a definite way to do it.

    The real implementation we have today just uses the JNI interface to call the public static void main (String args[]) method by using this function, so you could easily write exactly the same code if you wanted using JNI and have a different method to load your app.

    Here's an example in code that was taken from this page.

    Here's the current linux launcher program, the method lookup starts here.

提交回复
热议问题