Hi everyone,
I've search the forum about my problems but none of it seems to have solution to me, so I have to post this new topic, please understand for me.
I'm writing a program that will parse java.class file to get their public methods, I'm using two methods
clazz = Class.forName(className)
and
clazz.getDeclaredMethods();
At first, I encounter problem about
ClassNotFoundException at
Class.forName(className), I've do some research and know that it is caused when the java.class file I'm parsing is not in the classpath, so I've add them to my classpath.
ClassNotFoundException has gone, means that I can go to the next line of code
clazz.getDeclaredMethods(), but then I encounter another problem
NoClassDefFoundError org.eclipse.core.runtime.IProgressMonitor.
The class I'm parsing using class
org.eclipse.core.runtime.IProgressMonitor in jar file
org.eclipse.equinox.common_3.2.0.v20060603,
I guess that I need to load this jar file into my class loader, so I create my custom URLClassLoader as below
public class JarFileLoader extends URLClassLoader
{
public JarFileLoader (URL[] urls)
{
super (urls);
}
public void addFile (String path) throws MalformedURLException
{
String urlPath = "jar:file:" + path + "!/";
addURL (new URL (urlPath));
}
}
In my code, before parsing the java.class file I've loaded all the jar file neccessary into my JarFileLoader using
jarFileLoader.addFile(filePath);
, then I use
clazz = jarFileLoader.getClass(className)
clazz.getDeclaredMethods();
to get methods of java.class, but
NoClassDefFoundError org.eclipse.core.runtime.IProgressMonitor still happens, Is there any error with my custom URLClassLoader, please help me with these problems