This week's book giveaway is in the OCAJP forum. We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line! See this thread for details.
Is this how I properly make it use my AppClassLoader?
posted 12 years ago
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?