Consistent and stubborn problem
Hi everyone. When I try to run a java program, or any .java file for that matter, I keep getting a "Exception in thread "main" java.lang.NoClassDefFoundError". It's happening with all my .java, .jar, and .class files. What can I do to fix this problem? It only started happening recently.
[296 byte] By [
ApRiXa] at [2007-11-27 5:39:42]

The first time this happened it actually happened kind of randomly, I've never had this problem before. However, if it is a classpath issue, I don't know what I have to do with it to fix the problem. Where is the classpath supposed to lead to? Perhaps I can double-check it.
ApRiXa at 2007-7-12 15:15:12 >

Well actually just for the sake of testing I made a very simple application that just prints "Hello World!" on the screen named Demo.java. It compiles, making a Demo.class and then the error shows up when I type "java Demo". I know I DO I have a main class because it explicitly says "public class Demo() {" at the top!
Message was edited by:
ApRiX
ApRiXa at 2007-7-12 15:15:12 >

Thanks for the reply. However, I got the same error! When I first installed Java I only added ".;" (without the quotes) to the beginning of the CLASSPATH line, and it worked fine until now.
ApRiXa at 2007-7-12 15:15:12 >

> Thanks for the reply. However, I got the same error!> When I first installed Java I only added ".;"> (without the quotes) to the beginning of the> CLASSPATH line, and it worked fine until now.Post the full error message.Kaj
kajbja at 2007-7-12 15:15:12 >

Alright, at command prompt I type in "java Demo"
It says : Exception in thread "main" java.lang.NoSuchMethodError: main
I put a ".;" at the beginning of my classpath and then it came up with this error instead of the NoClassDefFoundError. It is still coming up with this error with every java application I try to run.
ApRiXa at 2007-7-12 15:15:12 >

> It says : Exception in thread "main"
> java.lang.NoSuchMethodError: main
That means that the class can be found, but that it doesn't have a main method (just as it says). You must have a main method with correct signature if you want to be able to execute it as an application.
Kaj
kajbja at 2007-7-12 15:15:12 >

> Amazing! I must have forgotten to add that> constructor, but now it runs. Thank you!That's not a constructor, before that takes root in your terminology!