*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I Can Watch "I Can New topic
Author

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:
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

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,
Ryo
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.
Julia
Cindy Glass
"The Hood"
Sheriff

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: http://aspose.com/file-tools
 
subject: I Can't Run any Java Programs!
 
Similar Threads
(newbie) error message when starting the j2ee server
2 Questions - I'm Really At A Loss!
I Can't Run any Java Program!
Classpath question
2 Questions - I'm really at a loss!