Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's not entirely clear what you're really asking, but the <a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-5.html#jvms-5.2">JVM specification section 5.2</a> covers at least some of this:</p> <blockquote> <p>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 the 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.</p> <p>In an implementation of the Java Virtual Machine, the initial class could be provided as a command line argument. Alternatively, the implementation could provide an initial class that sets up a class loader which in turn loads an application. Other choices of the initial class are possible so long as they are consistent with the specification given in the previous paragraph.</p> </blockquote> <p>The <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.1">JLS section 12.1</a> has some other descriptions too.</p> <p>The JVM invokes the <code>main</code> method directly - it doesn't need to create a new object to do so. Although the <code>main</code> method itself has to be public, the class it's declared in doesn't. For example:</p> <pre><code>public class Test { private static class EntryPoint { public static void main(String[] args) { System.out.println("Hi"); } } } </code></pre> <p>Then execute with:</p> <pre><code>java 'Test$EntryPoint' </code></pre> <p>It prints "Hi" as expected.</p> <p>No code outside the <code>Test</code> class has access to <code>EntryPoint.main()</code> other than through privileged reflection - or direct access that the JVM is clearly capable of.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload