You are on page 1of 2

www.oracle.

com/academy

Java Programming
9-2: ClassLoader
Practice Activities

Lesson Objectives:
• The Class Loading Overview

• ClassLoader loading procedure

• JDK ClassLoader Class

• ClassLoader Hierarchy

• Custom ClassLoader

• Class Linking

Vocabulary:

Identify the vocabulary word for each definition below.

The ClassLoader that loads classes from the core Java libraries

The ClassLoader that loads classes from the JAR files located in the
extensions directories

The ClassLoader that loads the application class, which can come from
a directory or JAR file on the class path.

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
respective owners.
2

Try It/Solve It:

Write a program to use the ClassLoader to load the Loaded Class and instantiate the Loaded Class instance.

Given the following class that will be loaded by the custom class loader:

public class HelloClass{

static{

System.out.println("HelloClass has been initialized");

public void sayHello(){

System.out.println("Hello Class Loader");

1. Write a MyclassLoader that inherits the abstract ClassLoader class to override the findClass method, and that will load
the HelloClass from the specified Path.

2. Write a TestClassLoader program to load the HelloClass.

3. Modify the TestClassLoader to load the class twice, and check the output to observe two HelloClass to be loaded and
initialized.

Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their
respective owners.

You might also like