I define my own class on an android program, say "MyClass", but when I
use the following code to do forName, ClassNotFoundException is
thrown:

Class MyClass {
}

void doForname() {
    Class.forName("com.sleepycat.je.Database", true,
Thread.currentThread().getContextClassLoader());
}

But, if I change doForname to
void doForname() {
    Class.forName("com.sleepycat.je.Database");  //do not use
Thread.currentThread().getContextClassLoader()
}

The class of MyClass can be successfully fetched.

Further more, if I use getContextClassLoader() for other class
existing in android, e.g.,
Class.forName("android.app.Activity", true, Thread.currentThread
().getContextClassLoader());
or
Class.forName("java.io.File", true, Thread.currentThread
().getContextClassLoader());
foName can run successfully.

To sum up, using Thread.currentThread().getContextClassLoader() cannot
forName the customer-defined class.

Who can tell me why?
Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to