Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: ClassNotFoundException - Please Help

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Question 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


  2. #2
    Junior Member
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default 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

  3. #3
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default 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

  4. The Following User Says Thank You to chronoz13 For This Useful Post:

    igniteflow (August 26th, 2009)

  5. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,282
    My Mood
    Happy
    Thanks
    70
    Thanked 158 Times in 154 Posts

    Default 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

  6. The Following User Says Thank You to Json For This Useful Post:

    igniteflow (August 26th, 2009)

  7. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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.

  8. The Following User Says Thank You to helloworld922 For This Useful Post:

    igniteflow (August 26th, 2009)

  9. #6
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default 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

  10. The Following User Says Thank You to chronoz13 For This Useful Post:

    igniteflow (August 26th, 2009)

  11. #7
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: ClassNotFoundException - Please Help

    anyway ignite i'd go with what Json said , maybe you might missing some import statements with your program

  12. The Following User Says Thank You to chronoz13 For This Useful Post:

    igniteflow (August 26th, 2009)

  13. #8
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,282
    My Mood
    Happy
    Thanks
    70
    Thanked 158 Times in 154 Posts

    Default 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

  14. The Following User Says Thank You to Json For This Useful Post:

    igniteflow (August 26th, 2009)

  15. #9
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default 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 ..

  16. The Following User Says Thank You to chronoz13 For This Useful Post:

    igniteflow (August 26th, 2009)

  17. #10
    Junior Member
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default 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.

  18. #11
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Smile 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.

  19. The Following User Says Thank You to chronoz13 For This Useful Post:

    igniteflow (August 26th, 2009)

  20. #12
    Junior Member
    Join Date
    Oct 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ClassNotFoundException - Please Help

    Quote Originally Posted by chronoz13 View Post
    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.