I'm trying to dynamically load a jar file, then load the classes
inside the jar. The code is simple but I keep getting ClassNotFind
exception. The class is in the jar. How can I figure out what is
wrong?
import java.net.URL;
import java.io.IOException;
import java.net.URLClassLoader;
import java.net.MalformedURLException;
import android.util.Log;
public class JarFileLoader extends URLClassLoader {
public JarFileLoader(URL[] urls) {
super(urls);
}
protected void addFile (String path) throws MalformedURLException
{
String urlPath = "jar:file://" + path;// + "!/";
addURL (new URL (urlPath));
}
public static void loadjar()
{
URL[] urls = {};
// load sprint jar
JarFileLoader cl = new JarFileLoader (urls);
try {
cl.addFile("C:/working/Adroid/workspace/my.jar");
cl.loadClass("com.mycompany.internal.Manager"); // !!!!! ClassNotFind
exception here !!!!!
} catch (Exception e) {
// TODO Auto-generated catch block
Log.i("JarFileLoader", e.getMessage());
e.printStackTrace();
}
Log.i("jarloader", "Success!");
}
}
Anyone has done dynamic jar and class loading please help.
Thanks,
Sherry
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---