-
Java error
I made a file using notepad. Saved x.java. CMD>File directory>javac x.java. Two files came to my desktop x.class and x$.class. I typed "java x" in right directory and this error came:
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: guesscolor (wr
e: GuessColor)
at java.lang.ClassLoader.defineClass1(Nativ… Method)
at java.lang.ClassLoader.defineClass(Unknow… Source)
at java.security.SecureClassLoader.defineCl… Source)
at java.net.URLClassLoader.defineClass(Unkn… Source)
at java.net.URLClassLoader.access$100(Unkno… Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivile… Method)
at java.net.URLClassLoader.findClass(Unknow… Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadCla… Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoad… Source)
And when I type " java x.class " it gives me this:
Code:
Error: Could not find or load main class x.class
So my question is, how can I fix those errors and make it run properly?
-
Re: Java error
probably the signature of the main() is wrong. can you show how your main() is declared?
-
Re: Java error
You mean that?
Code:
public static void main(String[] args){
x c = new x();
c.start();
}
-
Re: Java error
A) x is a bad class name. Java classes should be leading cap, and longer than one letter.
B) guesscolor and GuessColor are not the same class. NoClassDefFoundError is your culprit.
C) until the program compiles, it will not run with java.exe. Get the compiler errors to go away first. You may want to try an IDE (Eclipse, NetBeans, etc.) which can help you identify missing classes/bad name prior to compile time.
-
Re: Java error
Please go through the Forum Rules -- particularly the third paragraph.
db
-
Re: Java error
I tried to hide the name lol. It's guesscolor class. So how can I fix the problem(s)?
-
Re: Java error
Come on this is urgent :(
-
Re: Java error
I'm sorry, I shouldn't bump this much but this is really urgent. It has to be done in 2 hours :( I tried my parents, teacher and yahoo ask but still nothing. Please if you got anything to ask or you know the answer or anything please just post :l
-
Re: Java error
-
Re: Java error
Quote:
Originally Posted by
DarrylBurke
Thnx, didn't help atall though. Luckily I got more time now. Its still urgent.
-
Re: Java error
Quote:
Originally Posted by
Kazkar
Thnx ...
Didn't you learn anything from the page I linked?
db
-
Re: Java error
Once again: guesscolor and GuessColor are NOT the same to the java compiler.
Using an IDE (Eclipse, NetBeans, etc.) will help you find these. Many IDEs for Java are free to download and use.
-
Re: Java error
Theres nothing wrong with source code.. Too late now, thanks for trying -.-