aspose file tools*
The moose likes Java in General and the fly likes Why JVM has 3 class loaders? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why JVM has 3 class loaders?" Watch "Why JVM has 3 class loaders?" New topic
Author

Why JVM has 3 class loaders?

sriram sundararajan
Ranch Hand

Joined: Apr 08, 2003
Posts: 43
Why JVM has 3 class loaders namely

  • Bootstrap or System Class Loaders
  • Extenstion Class Loaders
  • Application Class Loaders


  • Boot Strap - For Core Java API classes
  • Extenstion - Java extenstion classes
  • Application - All User defined classes


  • Why can't i have single class loader that do everything? Why JVM is providing 3 class loaders? I am sure there should be some radical thought behind this

    Ernest Friedman-Hill
    author and iconoclast
    Marshal

    Joined: Jul 08, 2003
    Posts: 24187
        
      34

    ClassLoaders provide part of Java's security model. A class is identified not only by its name, but by the ClassLoader that loaded it, and this ClassLoader can reliably be used to grant privileges to the class based on where it came from. java.* classes loaded from rt.jar are allowed to do things that, let's say, a downloaded applet class would never be allowed to do.

    Many JVMs contain far more than three classloaders -- a web container includes at least one for each webapp, for example.


    [Jess in Action][AskingGoodQuestions]
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39810
        
      28
    Moving thread as too difficult for "beginning".
    Seetharaman Venkatasamy
    Ranch Hand

    Joined: Jan 28, 2008
    Posts: 5575

    Ernest Friedman-Hill wrote:Many JVMs contain far more than three classloaders -- a web container includes at least one for each webapp, for example.


    I am not clear here . Jvm and web container are two different things right?
    Ernest Friedman-Hill
    author and iconoclast
    Marshal

    Joined: Jul 08, 2003
    Posts: 24187
        
      34

    A web container is often just a Java program that runs on the JVM, like Tomcat, Glassfish, etc. A Java program can create its own class loaders, so those three you name are just the starting point.
    Seetharaman Venkatasamy
    Ranch Hand

    Joined: Jan 28, 2008
    Posts: 5575

    thanks Ernest

    Ernest Friedman-Hill wrote:those three you name are just the starting point.


    by the way: thats not me . thats is sriram
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Why JVM has 3 class loaders?