• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is ClassLoader

 
vijay shanker
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wanted to understand what is java.lang.Class object and how does it work i am having problem to work with becouse i am not understanding the concept behind this
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15459
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A ClassLoader is an object that is responsible for loading *.class files and turning them into classes that the JVM can use.

See the API documentation of class ClassLoader, it explains it in more detail.

Google for "java classloader" and you'll find some documents that go deeper into the concept of classloaders.
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since a classLoader object is an object of type ClassLoader, how does a classLoader get loaded?
 
Henry Wong
author
Marshal
Pie
Posts: 21446
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kaydell Leavitt:
Since a classLoader object is an object of type ClassLoader, how does a classLoader get loaded?


If memory serves, there is a bootstrap class loader, in the JVM. This class loader is responsible for loading the runtime classes. In these classes is another classloader that is responsible for loading the classes from the classpath.

And if you intend to write your own classloader, so that you can load classes from another source, you are supposed to place your classloader in the classpath.

Henry
 
vijay shanker
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Henry Wong:


If memory serves, there is a bootstrap class loader, in the JVM. This class loader is responsible for loading the runtime classes. In these classes is another classloader that is responsible for loading the classes from the classpath.

And if you intend to write your own classloader, so that you can load classes from another source, you are supposed to place your classloader in the classpath.

Henry



But what does it mean when you say "load the classes". is this same as making an object of class that will be available to program to call methods
of that class.
 
Henry Wong
author
Marshal
Pie
Posts: 21446
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vijay shanker:

But what does it mean when you say "load the classes". is this same as making an object of class that will be available to program to call methods
of that class.


If you wamt to write your own class loader, please google for information on how to do this.... basically... the class loader will load the bytecodes (the class file). Once the class loader has the byte codes in a byte array, it will call a method called defineClass(), which does all the stuff need by Java -- including creating the Class object.

It also does other stuff, which is why I recommend that you google for more information, if you are interested.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic