|
-
April 3rd, 2012, 12:59 PM
#1
Sudden CLASSPATH errors have halted my progress
I have a Netbeans project with a CLASSPATH problem that came out of nowhere and I cannot solve. What's especially maddening is that everything compiled and ran fine until Sunday. On Sunday I changed the parental order of components in the design view and now nothing works.
Aside from core Java code like Swing, this is a project where all of the code is based within the project itself. Everything is grouped into 5 different packages, but they are all within the project.
After changing that parental order I would get either one or the other error: NoClassDefFoundError and ClassNotFoundException (I'm going on memory on those names) that would happen inconsistently.
I decided to delete my app's main Frame class and recreate it. Now when I drag my custom components to the Frame to rebuild some classes give me:
"Cannot load component [package].[file] from project:
[full path to my project]
The class must be compiled and must be on the classpath of the project to which this form belongs"
If I forcibly add the source's path to: Project Properties ==> Libraries ==> Compile
I get this error when attempting to add my component to my default Frame class in design view:
"The component cannot be instantiated. Please make sure it is a JavaBeans component."
I've done all of the basics to fix the problem:- I've restarted Netbeans.
- I've rebooted.
- I've cleans and rebuilt numerous times.
- I have closed an of the windows within Netbeans to ensure I'm not accidently pulling similar files from other projects
NOTHING HELPS!
Then I tried more advanced stuff. I created a flat version of my project so that everything is in the same package. "How could CLASSPATH errors occur now?" I thought, but I still got errors! I even moved everything into the default package and continued to get that "The component cannot be instantiated..." error!
I avoided modifying the CLASSPATH until today. From what I've read, CLASSPATH is a lot like the PATH environment windows uses to search for DLLs: CLASSPATH is used system-wide so any Java tool like "java" or "javac" will use the paths. Obviously the system-wide CLASSPATH should not be modified, but I thought that even the project-level CLASSPATH shouldn't be modified either. Shouldn't Netbeans be smart enough to figure out the appropriate CLASSPATH for files LOCAL to the project?
I changed it anyway and still get errors.
A CLASSPATH error doesn't even make sense in this situation.
- 1) All of the classes used in my project are either default-Java classes (Swing etc) or classes defined within the project itself. I have no need to search elsewhere, so why would a project designed like that ever need to override the CLASSPATH setting?
- 2) According to the docs, the default CLASSPATH is the current directory. So why do I continue to get errors after pulling all of the classes out of their packages and move them into the same package? Even when I move them to the default package the errors remain!
- 3) Considering these exact same classes built and ran fine once, why would moving their position (and parental hierarchy) on the GUI builder affect java & javac's ability to find these classes?
If my CLASSPATH error is a legitimate CLASSPATH error then certainly moving all of my classes into the same place would solve this. Since it doesn't I'm forced to conclude this is somehow a problem with my code that's not caught by the compiler or a bug in Netbeans.
Here's the main document I used for this research:
http://docs.oracle.com/javase/1.3/do...classpath.html
Why are the "tolerant" so easy to offend?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|