This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I know that in my code, I can use my own classloader (that i wrote) to load classes. Is there a way to make your main class loaded by this classloader? In other words, when i start up with: java blah can i make blah loaded by my classloader: NClassLoader? Say with a -D call or something? Is there a way to do it for a jar file too?
OK - so I am confused about the question. When you invoke a program using >java blah the class IS automatically loaded by the bootstrap class loader and the main class invoked for you. If you invoke a jar file, the manifest in investigated to identify the name of the class that contains the main method that you want invoked at startup. That means that the containing class is loaded first. Is that your question?
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Sep 29, 2000
Oh - I think that I get it. You want to use YOUR classloader. In that case you probably need a driver class that gets loaded by the bootstrap classloader and have IT call your class with your classloader.