MyClass.java Source code

Java tutorial

Introduction

Here is the source code for MyClass.java

Source

class MyClass {
    static {
        System.out.println("Loading class MyClass...");
    }
}

public class Main {
    public static void main(String[] args) {
        try {
            String className = "MyClass";
            boolean initialize = false;

            ClassLoader cLoader = Main.class.getClassLoader();
            Class c = Class.forName(className, initialize, cLoader);
            className = "MyClass";
            System.out.println("about to load");
            // Will load and initialize the class
            c = Class.forName(className);
        } catch (ClassNotFoundException e) {
            System.out.println(e.getMessage());
        }
    }
}