I have a NetBeans project set up with a bunch of source classes and about 10 jUnit test classes in a separate Test folder.
From within the Test files I can import any other test file or source class. However, from within the normal source files, NetBeans acts as if the Test classes don’t exist. Autocomplete on them won’t work, and if I attempt to use them I get a compile error.
I understand that normally it wouldn’t make sense to use a Test class from the regular source, but I have a good reason in this case. Part of my program accepts a class name as a string and creates and instance of it with reflection. One of my jUnit tests calls this method to test it, and passes it the name of a Test class. This always fails because the normal program code can’t find any of the classes from the Test folder.
While running a test the classpath will include the source and test classes. They must, and I don’t think it would really be possible to prevent one from accessing the other at runtime, even with class loaders. I certainly highly doubt that Netbeans is doing it, even if it is theoretically possible.
There are two possibilities that I could guess at. One is that the error is not what you think it is. If you post a stack trace, we could help you with that.
The other is that you are using the wrong class loader to load the class (i.e. not just using Class.forName()). Can you post the code snippit doing the class loading?