How is the Java Bootstrap Classloader loaded?

36,531

Solution 1

Answer : When a JVM starts up, a special chunk of machine code runs that loads the system classloader. This machine code is known as the Bootstrap / Primordial (or sometimes - Null) classloader.

It is not a Java class at all, as are all other classloaders. The bootstrap classloader is platform specific machine instructions that kick off the whole classloading process.

All classloaders, with the exception of the bootstrap classloader, are implemented as Java classes. Something must load the very first Java classloader to get the process started. Loading the first pure Java classloader is the job of the bootstrap classloader.

The bootstrap classloader also takes care of loading all of the code needed to support the basic Java Runtime Environment (JRE), including classes in the java.util and the java.lang packages.

Source: http://www.theserverside.com/tutorial/Classloaders-Demystified-Understanding-How-Java-Classes-Get-Loaded-in-Web-Applications

Solution 2

The Bootstrap Classloader, being a classloader and all, is actually a part of the JVM Core and it is written in native code.

Classloaders can be objects, they need a representation too. In fact, this also allows the creation of user-defined classloaders.

Solution 3

There is an idiom in English, "He pulled himself up by his bootstraps." The boot straps are the little handles of the top sides of boots and, of course, its impossible.

http://en.wikipedia.org/wiki/Booting

The article explains the process of booting a computer, which is short for bootstrapping.

What happens with every program of every type is that a loader of some sort copies some bytes into memory somewhere and begins execution at a predefined place in those bytes.

For Java, the boot strap loader may or may not be a Java class. (Someone probably knows.) But it is a program of some sort that loads the very first few classes into memory and causes the JVM to begin executing those bits of loaded Java code. Maybe it loads the JVM code itself. Maybe it just makes sure some prior bit of code loaded the JVM. Maybe, it even requires the JVM to have already been loaded and running.

Its just part of the process.

Solution 4

JDK installed path: jdk\jre\lib\rt.jar

this location is called bootstrap class path. Bootstrap class loader is responsible to load classes from bootstrap class path.

Bootstrap class loader is by default available with the JVM. It is implemented in Native Language Like C and C++.

Share:
36,531
Sunny Gupta
Author by

Sunny Gupta

I am a Java Developer

Updated on August 01, 2020

Comments

  • Sunny Gupta
    Sunny Gupta almost 4 years

    In java, it is said that all the classes are being loaded by classloaders.

    So first of all, bootstrap classloader loads all the rt.jar classes.

    So I am still confused as Classloader is also a class, so who will load this BootStrapClassloader.

    Kindly explain.

  • Raúl
    Raúl about 9 years
    Two cents: 1) Thanks for reminder, I just upvoted. 2) First half of this answer is good. Second half is full of un-certainty. I did added mu bits to it, but someone didn't considered them appropriate.
  • Raúl
    Raúl about 9 years
    If you are looking for complete answer, read my answer below. (I am not blowing my trumpet, but it have the answers of all may-bes)
  • Lee Meador
    Lee Meador almost 9 years
    @Raúl My point was that it doesn't matter what kind of code is loading the code in each step of bringing up Java. It goes without saying that, on each OS, it has to be native code that starts running. An OS only loads native code. It brings in something small which loads something larger. The process repeats with each thing loaded, in turn, loading something larger until its all there. The smaller the first part, the less native code is needed for each OS and the more common code for all OSes. But it doesn't matter how many stages there are to loading.
  • Lee Meador
    Lee Meador almost 9 years
    It's hard to tell whether you are saying all classloaders are NOT Java classes. Maybe you are saying all classloaders ARE Java classes. The use of commas makes it ambiguous. (This is in the 1st sentence of your 2nd paragraph.)
  • Raúl
    Raúl almost 9 years
    I mean, in Java environment - only Bootstrap CL will be a non java (native) class loader; rest of them (System, Application, user defined CLs etc) are Java Class Loaders............. pls see the link.
  • Raúl
    Raúl almost 9 years
    Yes, fully agree :-)