Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why JVM has 3 class loaders?

 
sriram sundararajan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Pie
    Posts: 24208
    35
    Chrome Eclipse IDE Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Campbell Ritchie
    Sheriff
    Posts: 48404
    56
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Moving thread as too difficult for "beginning".
     
    Seetharaman Venkatasamy
    Ranch Hand
    Posts: 5575
    Eclipse IDE Java Windows XP
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 24208
    35
    Chrome Eclipse IDE Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 5575
    Eclipse IDE Java Windows XP
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks Ernest

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


    by the way: thats not me . thats is sriram
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic