Results 1 to 2 of 2
  1. #1
    bugger is offline Senior Member
    Join Date
    Nov 2007
    Posts
    111
    Rep Power
    0

    Default Private main method

    I tried the following:
    Java Code:
    public class T {
    private static void main(String[] str)
    {
    System.out.println("test");	
    }
    }
    It does not give me any errors at compile time (I am using Eclipse 3.3). When I try to run it, it says "Main method not public". Makes sense.

    But I would like to know, why main method should always be public. This method is not called by other classes directly.

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    10

Similar Threads

  1. Calling main method
    By eva in forum New To Java
    Replies: 7
    Last Post: 11-06-2009, 02:37 PM
  2. Main method with throws Exception
    By bugger in forum New To Java
    Replies: 3
    Last Post: 01-07-2008, 03:48 PM
  3. A query about main method
    By mew in forum New To Java
    Replies: 2
    Last Post: 12-24-2007, 10:44 AM
  4. main method
    By eva in forum New To Java
    Replies: 5
    Last Post: 12-19-2007, 10:25 AM
  5. The main method in java...
    By lenny in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 06:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •