• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Java Class Loaders

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please explain about the various java class loaders and how do they load the classes and in what order?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, and welcome to the Ranch!

You'll find if you ShowSomeEffort(⇐click) and SearchFirst,(⇐click) you'll have a much more productive experience here. Note that this site is more geared toward answering specific, targeted questions than to providing overviews of broad topics.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

VaibhavG Garg wrote:Please explain about the various java class loaders and how do they load the classes and in what order?


My advice: Don't worry about it. I never have in 11 years of writing Java.

Winston
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I disagree with Winston. While classloaders can generally be ignored for desktop apps, understanding them is important for servlet containers and app servers. What's more, classloader based technologies like OSGi can be very powerful tools for all apps, even on the desktop.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:I disagree with Winston. While classloaders can generally be ignored for desktop apps, understanding them is important for servlet containers and app servers. What's more, classloader based technologies like OSGi can be very powerful tools for all apps, even on the desktop.


OK, I should probably have said "don't worry about it yet" (consider the source forum). If and when you need to use them, you will hopefully be furnished with proper instructions, but for a beginner I suspect it's just information overload.

Winston
 
Vaibhav G Garg
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read different topics about Class Loaders in Java. Now, I have following queries. Please help in me resolving these queries:

i. The class loaders are in following hierarchy Bootstrap > Extensions > System. Now, Extensions class loader loads the jars from jre/lib/ext folder. But, why there is a separate class loader specifically for these jars?

ii. As per the topcis, the Bootstrap Loader loads the java.lang.*, java.util.* package classes. But, when I wrote the following piece of code, it is printing NULL. Why the class loader is coming as NULL here. It should have printed the Bootstrap Class Loader name here. Am I missing something over here?

 
Vaibhav G Garg
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have read a lot about the CLass Loaders and found this. When a class loader is entrusted with the responsibility of loading a class, as a first step it delegates this work to the associated parent class loader. Then this parent class loader gets the instruction and sequentially it delegates the call to its parent class loader. In this chain of hierarchy the bootstrap class loader is at the top.

Can anyone please explain what is the use of delegation model here in loading the classes when everything will be loaded by BootStrap loader only?
 
Marshal
Posts: 78675
374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving thread as too difficult for “beginning”.
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic