• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I Can't Run any Java Programs!

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All of a sudden, my Java programs won't run. They compile OK, but when I try to run them, I get the following error message:
"Exception in thread "main" java.lang.NoSuchMethodError - main
My source and object files are in c:\java.
My c:\autoexec.bat looks as follows:
path=c:\windows;c:\windows\command;c:\jdk1.3.0_02\bin;c:\java;.
set classpath=c:\jdk1.3.0_02\lib\tools.jar;c:\java;.

Why am I getting this run-time error all of a sudden? These programs used to run OK. Does anyone have any idea? Any help would be greatly appreciated. Thanks!
Gary Farms
 
Ranch Hand
Posts: 218
VI Editor Ruby Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, according to the Error the VM is looking for your "main"
method. Double check to see if you have it and make sure
the signature are: public static void main(String[] args)
any other signature won't do.
Good luck,
Ryo
 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sometimes it is better to have the current directory at the front of the classpath, so it is better to set classpath like this:
set classpath = .;%classpath%
This error is almost always a classpath error.
Julia
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, Ryo is right. If it was a classpath problem you would be getting a class not found error. Therefore the JVM is finding the file, just not the main method.
You know that last time someone REALLY had problems like this, it turned out that he had set up a Macro to spit out the
"public static void main(String args[]){"
line, and the macro was putting some non-visible character on the line that made the JVM not recognize the signature for main.
Try retyping that whole line by hand and re-compiling.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic