File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes I Can't Run any Java Programs! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I Can Watch "I Can New topic

I Can't Run any Java Programs!

Gary Farms
Ranch Hand

Joined: Jun 24, 2000
Posts: 57
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:
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

Joined: Mar 20, 2001
Posts: 210

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,
Julia Reynolds
Ranch Hand

Joined: May 31, 2001
Posts: 123
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.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
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.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: I Can't Run any Java Programs!
It's not a secret anymore!