• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Any way to make main class loaded by your classloader?

 
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic