File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I Can't Run any Java Programs!

 
Gary Farms
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Wirianto Djunaidi
Ranch Hand
Posts: 210
Ruby Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Julia Reynolds
Ranch Hand
Posts: 123
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic