O'Reilly logo

Component Development for the Java™ Platform by Stuart Dabbs Halloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.3. Explicit and Implicit Class Loading

The simplest class loading API is provided by the ClassLoader class shown in Listing 2-2.

Listing 2-2. Explict Loading with ClassLoader
package java.lang;
public class ClassLoader {
 public Class loadClass(String n)
        throws ClassNotFoundException;
 //remainder omitted for clarity
}

This is fairly straightforward. You pass in the full name of the class, delimiting packages with dots, and you get back a distinguished Class object that represents the loaded class. If the class loader fails, it throws the checked ClassNotFoundException.

2.3.1. Explicit Loading with URLClassLoader

The easiest way to see loadClass in action is to use a concrete ClassLoader implementation provided by the core API. By far, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required