File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Any way to make main class loaded by your classloader?

 
Robert Paris
Ranch Hand
Posts: 585
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic