I'm actually trying to see how I could invoke instances of classes for which
I known the name only at runtime. So I thought to use the "forName()" method
of the "Class" class. Unfortunately, when running my test code, I always
get an exception saying that the class could not be found. Anyone could give
me a tip how to use that "forName" method.

Here's my test code (2 classes):

class RunMe {
public static void main(String args[]) {
try {
System.out.println("Loading the class");
Class oClass = Class.forName("LoadedClass.class");
catch (Exception e) {

class LoadedClass {
public static void main(String args[]) {
System.out.println("i'm the loaded class");

I also tried to package the "LoadedClass.class" in a jar file, add it to
my classpath but I got the same result.

PS: Sorry if this is a stupid question, I'm starting to really look how to
program in Java.