This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi All, I have a really good problem here. Hopefully there is an expert out there that can help me figure it out or already has the answer. I have built a custom ClassLoader extending the java.lang.ClassLoader. I use this ClassLoader (not important why I need it) to load a class X. This class X uses some native methods, so I load the dll with System.load("blah.dll"); inside Class X. Everything seems to work fine when I load class X, but intermittently I get an "UnsatisfiedLinkError: Native library <blah.dll> already loaded in another ClassLoader." There does not seem to be a pattern as to when this happens. Sometimes I can load class X 20 times before this happens, and sometimes only a few times. It's very strange. Is there a way to check if a dll is already loaded before trying to load it? I suppose I could catch the UnsatifiedLinkException, but then I don't know what to do once I've caught it. I could probably load the dll once at the beginning of the program, but I would like the load to happen inside class X for a more OO approach. Anyway, if anyone has any suggestions, I would love to hear. Many many thanks!! Barry P.S. If I let JVM handle class loading, I don't get this problem at all.