Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4155575

(launcher) main method should have to be public

XMLWordPrintable

    • beta2
    • generic, x86, sparc
    • generic, solaris_2.4, solaris_7, windows_95, windows_98, windows_nt

      In 1.2Beta4 it is no longer required that the main method of an application
      be public. This is true for both java and oldjava, and is an incompatible
      change from 1.1.


      Name: tb29552 Date: 09/06/99


      /*
      see,
        I had written a simple application with the main method as
      */

      public class psvm {
        private static void main(String[] args) {
          System.out.println("works ");
        }
      }
      /*

      Can you tell me how the jvm can call the private method main.

      I did it under 1.1.x and it reports an error:
        "In class psvm: main must be public and static"

      but under 1.2.. it just executed and gave the output.
      */

      (Review ID: 94901)
      ======================================================================

      Name: rmT116609 Date: 02/21/2001


      output is fine...but how is private main() method is getting inherited

      Could any one please explain that how private main() method is getting
      inherited in DerivedClass from BaseClass, you can save the below mentioned
      code as DerivedClass.java and run as java DerivedClass, the output is "This
      is Base Class main. I am using jdk1.3.



      // File: DerivedClass.java
      class BaseClass {
          private static void main(String[] a){
              System.out.println("This is Base Class main");
          }
      }

      public class DerivedClass extends BaseClass {
      }
      (Review ID: 117419)
      ======================================================================

            gafter Neal Gafter (Inactive)
            dconnellsunw David Connelly (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: