[ajug-members] why? NoSuchMethodError: main

jmhigginsth at checkfree.com jmhigginsth at checkfree.com
Fri Aug 10 10:12:51 EDT 2007


http://forum.java.sun.com/thread.jspa?threadID=736543&messageID=4231071 has
a thread discussing returning an exit code from Java to Unix.  Seems an
oversight to have made such a common script function so complex...

/James



                                                                           
             "Ron Cordell"                                                 
             <ron.cordell at gmai                                             
             l.com>                                                     To 
             Sent by:                  "General AJUG membership forum      
             ajug-members-boun         (100-200 messages/month)"           
             ces at ajug.org              <ajug-members at ajug.org>             
                                                                        cc 
                                                                           
             08/09/2007 03:38                                      Subject 
             PM                        Re: [ajug-members] why?             
                                       NoSuchMethodError: main             
                                                                           
             Please respond to                                             
               "General AJUG                                               
             membership forum                                              
                 \(100-200                                                 
             messages/month\)"                                             
             <ajug-members at aju                                             
                  g.org>                                                   
                                                                           
                                                                           




It's possible in C#, but I don't think it was ever possible in Java...

On 8/9/07, Tim Watts <timtw at earthlink.net > wrote:
  Thanks everyone. int was the problem.

  I must be losing my mind. I could swear I've done this successfully
  before.
  Was this EVER possible in Java (perhaps back in the 1.1 days)?

  On Thursday 09 August 2007 1:19 pm, Salman Khatri wrote:
  > And if you really want to return an error code back to the shell, you
  > can do so through java.lang.System.exit(n). If I am not mistaken, your
  > method becomes:
  >
  > public static void main(String[] args) {
  >       System.exit(new MakeConfigs.doMain(args));
  > }
  >
  >
  > Java always returns '0' on a normal, exception-less conclusion of your
  > program. It seems to return '1' on an exception. Please note that when
  > you run java without any parameters, it shows command line help and
  > returns a '0'.
  >
  > Jeremy Haile wrote:
  > > It needs to be "public static void main(String[] args)"
  > >
  > > Cheers,
  > > Jeremy
  > >
  > >
  > > On Thu, 9 Aug 2007 12:24:51 -0400, "Tim Watts" < timtw at earthlink.net>
  > >
  > > said:
  > >> Hi,
  > >>
  > >> I'm getting this when I run my utilty:
  > >>
  > >>    Exception in thread "main" java.lang.NoSuchMethodError: main
  > >>
  > >> The class has:
  > >>
  > >>    public static int main(String[] args) {
  > >>            return new MakeConfigs.doMain(args);
  > >>    }
  > >>
  > >> The class is public:
  > >>
  > >>    public class MakeConfigs {...
  > >>
  > >> And it's in the classpath (otherwise I wouldn't even get this error,
  of
  > >> course).
  > >>
  > >> I tried java -verbose... and it just tells me what jar it found the
  > >> class in.
  > >> I'm running under jdk 1.5, it's compiled for 1.4
  > >>
  > >> Any ideas what could be going on?
  > >> _______________________________________________
  > >> ajug-members mailing list
  > >> ajug-members at ajug.org
  > >> http://www.ajug.org/mailman/listinfo/ajug-members
  > >
  > > _______________________________________________
  > > ajug-members mailing list
  > > ajug-members at ajug.org
  > > http://www.ajug.org/mailman/listinfo/ajug-members
  _______________________________________________
  ajug-members mailing list
  ajug-members at ajug.org
  http://www.ajug.org/mailman/listinfo/ajug-members
_______________________________________________
ajug-members mailing list
ajug-members at ajug.org
http://www.ajug.org/mailman/listinfo/ajug-members
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ajug.org/pipermail/ajug-members/attachments/20070810/605ac846/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://www.ajug.org/pipermail/ajug-members/attachments/20070810/605ac846/attachment.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic01614.gif
Type: image/gif
Size: 1255 bytes
Desc: not available
Url : http://www.ajug.org/pipermail/ajug-members/attachments/20070810/605ac846/attachment-0001.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
Url : http://www.ajug.org/pipermail/ajug-members/attachments/20070810/605ac846/attachment-0002.gif 


More information about the ajug-members mailing list