Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

I see that in Java a lot of Class loaders: bootstrap, extension, system, context

JavaFAQ Home » General Java Go to all tips in General Java


Bookmark and Share

Question: I see that in Java a lot of Class loaders: bootstrap, extension, system, context and even user defined! It is difficult to understand Class loader hierarchy in Java.

Answer: It was much better in Java 1.1 time Smile
There were no relations between system class loader (responsible for loading in the Java runtime, the application, and classes and resources in the application's CLASSPATH) and applet class loader (loaded classes over networks).

Since Java 1.2 we have three types of class loaders:

  • Class loaders created automatically by the JVM
  • Program defined class loaders
  • Context class loaders.

There are three Class loaders in first group:

  • bootstrap class loader - loads classes from ../jre/lib/rt.jar It is the "root" in the class loader hierarchy.
  • extensions class loader - loads classes from ../jre/lib/ext/*.jar
  • system class loader - it is responsible for loading in the application, as well as for loading classes and resources in the application's CLASSPATH.

Second group includes:

  • system class loader - parent class loader by default
  • additional parent class loader can be specified explicitly

Third group is context class loader. A thread's context class loader is, by default, set to the context class loader of the thread's parent. The hierarchy of threads is rooted at the primordial thread (the one that runs the program). The context class loader of the primordial thread is set to the class loader that loaded the application. So unless you explicitly change the thread's context class loader, its context class loader will be the application's class loader. That is, the context class loader can load the classes that the application can load.
To change a thread's context class loader, use Thread.setContextClassLoader().


 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search



Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy