This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Is this how I properly make it use my AppClassLoader? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is this how I properly make it use my AppClassLoader?" Watch "Is this how I properly make it use my AppClassLoader?" New topic
Author

Is this how I properly make it use my AppClassLoader?

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
In Java 1.4, there's a System property "-Djava.system.class.loader" that allows you to make it use your classloader ass the application (or system) classloader. You need only one constructor: YourClassLoader(ClassLoader parent).
When I use the system property, it does instantiate my classloader (which extends URLClassLoader) but when I check on a class to see what loaded it, it says "sun.misc.Launcher$AppClassLoader" (hang on a sec). HOWEVER, if I pass null instead of "parent" to super(), then the classes which were loaded explicitly now say they were loaded by my classloader. Is this a proper way to do this? Am I right to pass null as the parent of my System classloader?
 
 
subject: Is this how I properly make it use my AppClassLoader?
 
Similar Threads
reading a properties file
classloader
Why getting ClassCastException?
Strange NoClassDefFoundError with obfuscated build
log4j.properties not found