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.
I can load standalone classes, but how can it be done for jar files without being too cumbersome?
P.S. I looked at URLClassLoader, but it requires you to call "loadClass" to load a user supplied class. I want to load *all* classes without instantiating a particular one, as if it were added using the "-cp" switch. [ March 23, 2006: Message edited by: Arvind Kumar Patel ]
I don't think you will find a way to do this with a simple function call from the API. However, you should be able to write a function that does this. I would start by looking at the classes in java.util.jar. You should be able to use these classes to iterate over the .class files in a jar file and load each one individually with URLClassLoader.
Originally posted by Arvind Kumar Patel: I looked at URLClassLoader, but it requires you to call "loadClass" to load a user supplied class. I want to load *all* classes without instantiating a particular one, as if it were added using the "-cp" switch.
Specifying a Jar on the classpath does not cause all its classes to be loaded. It just makes them available, should they need to be loaded.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Arvind Kumar Patel
Joined: Mar 11, 2006
Found a solution, the AddURL method in URLClassLoader works perfectly.