Quick personal background: I was hired a few months ago as the sole .NET developer (C#) by a company whose other devs are all php devs. A week into the job I was told they wanted to switch to Java instead of doing .NET. Not an ideal situation, but I m trying to make it work.
I don t think I understand the relation between a project s library and the class path. I am using NetBeans 6.7.1 for development. My current project is to create an application that will update multiple merchant sources (eBay, Amazon, etc). I created a Class Library project that handles scheduling of these updates. We ll call it Update.
I am in the process of creating Class Library projects for the various sources (e.g. eBay). I added the ebay project to the Update project as a Library. In the IDE there is a box that says "Build Projects on Classpath" which is checked.
Finally, right now I have a little console app that has the Update project referenced as a Library (so the ebay project is now 2 libraries deep) in the same manner. It works with code in the Update project.
This works OK until I get to instantiating a class (from the Update project via the console app) that is in the ebay project. At that point I get a
Exception in thread "main"
java.lang.NoClassDefFoundError
which is
Caused by: java.lang.ClassNotFoundException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
These projects all build fine but this runtime exception is killing me. I don t know if I really understand what adding a Library to a project does and if there is something more I need to do to make the class accessible. I m used to being able to add a reference to a DLL and being good to go. I don t understand why I don t get any compiler errors or build errors but I get run time errors about accessibility. I m guessing the classpath is a missing piece that I don t understand too well, although I suppose it s possible this problem has to do with something else entirely.