ClassLoader.loadClass

ClassLoader.loadClass

Class Overview | Class Members | This Package | All Packages

Syntax 1
public Class loadClass( String name ) throws ClassNotFoundException
Parameters
name
the name of the desired Class.
resolve
true if the Class must be resolved.
Returns
the resulting Class, or null if it was not found.
Description
Requests the class loader to load a class with the specified name. The loadClass method is called by the Java Virtual Machine when a class loaded by a class loader first references another class. Every subclass of class ClassLoader must define this method.

If the resolve flag is true, the method should call the resolveClass method on the resulting class object.

Class loaders should use a hashtable or other cache to avoid defining classes with the same name multiple times.

Exceptions
ClassNotFoundException if the class loader cannot find a definition for the class.



Syntax 2
protected abstract Class loadClass( String name, boolean resolve ) throws ClassNotFoundException
Parameters
name
the name of the desired Class.
resolve
true if the Class needs to be resolved.
Returns
the resulting Class, or null if it was not found.
Description
Resolves the specified name to a Class. The method loadClass() is called by the virtual machine. As an abstract method, loadClass() must be defined in a subclass of ClassLoader. By using a Hashtable, you can avoid loading the same Class more than once.

Exceptions
ClassNotFoundException if the class loader cannot find a definition for the class.
See Also
Hashtable