ClassNotFoundException - Please Help
I've been working on a program and everything was working fine, except now I'm getting a ClassNotFoundException for no reason I can trace. What would cause this?
I'm trying to call a method from another class in the same package which has always worked fine before. I can put my code up, but the program is pretty big so not sure where to start. Basically, I have a class called minAndMax which has a static method I want to use, it's when I try to access that withe the following code:
double minTest = minAndMax.findMinimum(test);
It throws the ClassNotFoundException. Please help, I have to have this finished next week, it was all going fine until this happened
Re: ClassNotFoundException - Please Help
A little more information. The class file is called minAndMax, it is part of the same package. It contains static methods which I call from other classes using the standard syntax:
minAndMax.findMinimum(test);
where findMinimum() is the method and test is the value I send to it. This was working fine, then while using netbeans I selected to safely delete a variable and instead it deleted the entire GUI class file which was about two months work. I had an older backup which I've replaced it with but now I get the following output:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: emergingpatterns/minAndMax
at emergingpatterns.dateConversion.findMonths(dateCon version.java:60)
at emergingpatterns.dataSplit.getUserInput(dataSplit. java:606)
at emergingpatterns.emergingPatt.AnalyseDataMouseClic ked(emergingPatt.java:906)
at emergingpatterns.emergingPatt.access$500(emergingP att.java:9)
at emergingpatterns.emergingPatt$6.mouseClicked(emerg ingPatt.java:155)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEvent Multicaster.java:253)
at java.awt.Component.processMouseEvent(Component.jav a:6219)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3265)
at java.awt.Component.processEvent(Component.java:598 1)
at java.awt.Container.processEvent(Container.java:204 1)
at java.awt.Component.dispatchEventImpl(Component.jav a:4583)
at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
at java.awt.Component.dispatchEvent(Component.java:44 13)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4229)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4150)
at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475 )
at java.awt.Component.dispatchEvent(Component.java:44 13)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
Caused by: java.lang.ClassNotFoundException: emergingpatterns.minAndMax
at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)
... 26 more
Re: ClassNotFoundException - Please Help
hi ignite, i cant help you regarding this matter
but i think this one can hand you a liitle bit of help
--url --ClassNotFoundException (Java Platform SE 6) - url
Re: ClassNotFoundException - Please Help
All I can say is that the class in question is not on the classpath. You might be missing an import somewhere.
Oh and by the way, your class naming is somewhat controversial. You might want to use a capital character as your first character when working with class names.
// Json
Re: ClassNotFoundException - Please Help
I'd do what Json suggested. You might also want to check your cases/spellings. What IDE/setup are you using? I remember having troubles setting up NetBeans (cause i'm a tard) to import packages correctly, or even use external classes.
without more info (code), there's not much we can do beyond that.
Re: ClassNotFoundException - Please Help
i'm using netbeans v6.7 and i neve ecounter such error like that.. and when im declaring classes and
objects im declaring it in a conventional way. uppercase for class and lower case initial with objects
anyway Json , i just want to ask... will i get some problem with spellings? when i use lower case intials with classes? will it have some compiling errors? coz when im trying to make some sample programs urgently., just an exericses
, sometimes i use lowercase letters but i never ecounter such error like classnotfoundexception
and helloworld what problems do you encounter in netbeans?? what version are you using...?
please give me some details helloword..... tnx anyway
P.S
please help me with my post.. "loop , passed and failed" i really need that....
tnx
Re: ClassNotFoundException - Please Help
anyway ignite i'd go with what Json said , maybe you might missing some import statements with your program
Re: ClassNotFoundException - Please Help
No I wouldn't say that using lower case class names will cause any problems but its just bad practise and it makes it harder to read the code in my opinion.
If you are still having problems with the ClassNotFoundException, hand us the code and I shall have a look at it for you.
// Json
Re: ClassNotFoundException - Please Help
tnx Json for clearing it out i thought i would make some problems in my program...
regarding that matter..
im just curious about what helloworld have said ..
Re: ClassNotFoundException - Please Help
Many thanks everyone for your help. I wasn't aware of the capitalisation of class names, so have changed all the classes to conform with that now and can see why it is easier to read. I think my original problem might have stemmed from changing the class names in NetBeans, in doing so it automatically inserted some comments in the first few lines of those classes. Once I removed these comments, reinstating the package command on the first line the program ran fine.
Re: ClassNotFoundException - Please Help
aw i think i remember that i've encouterd the same problem that you had
hahahah because of class names
it was the time when im writing a java program in DOS and then i've tried to save it with a class name "System"
hahaha and i ended up with a big mess
well im glad that you solved your problem.\m/
Re: ClassNotFoundException - Please Help
Quote:
Originally Posted by
chronoz13
hi ignite, i cant help you regarding this matter
but i think this one can hand you a liitle bit of help
l
All I can say is that the class in question is not on the classpath. You might be missing an import somewhere.
Oh and by the way, your class naming is somewhat controversial. You might want to use a capital character as your first character when working with class names.