Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Dynamic loading of jar files using custom classLoader
Dynamic loading of jar files using custom classLoader [message #604706] Tue, 16 February 2010 15:26 Go to previous message
Sönke Holsten is currently offline Sönke Holsten
Messages: 6
Registered: February 2010
Junior Member
I've been searching for possibilities to dynamically load jar files for quite a while and came across a custom classLoader I like ( http://www.javaworld.com/javaworld/javatips/jw-javatip70.htm l). I downloaded the resources from that site (JarClassLoader.java, JarResources.java and MultiClassLoader.java) and put them to use in a small test project which worked out fine. However I want to use the JarClassLoader inside an Eclipse plug-in and for some reason I haven't been able to simply reuse the code from the test project for that purpose. The code I'm using in both the java test project and in the plug-in project is the following:

public static void run() {
JarClassLoader jarLoader = new JarClassLoader ("C:\\somepath\\testjar.jar");
try {
Class c = jarLoader.loadClass ("TestClass", true);
Object o = c.newInstance();
if (o instanceof TestClass) {
System.out.println("works...");
TestClass tc = (TestClass) o;
String test = tc.run();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}

In the normal java project I have a main method which just calls the method run() and does nothing else. In the Eclipse plug-in project I have an action that when executed also just calls the method run() and nothing else. The problem is that in the Eclipse plug-in the check whether the created object is an instance of the class I desire fails, that is "works..." is never even printed. Although in debug mode it says that the object o is actually an instance of the class TestClass.

Can anyone point me to what I might be doing wrong?

Thank you for your help!
 
Read Message
Read Message
Previous Topic:Adding an item to the Source/generateGroup????
Next Topic:headless build issues/bugs
Goto Forum:
  


Current Time: Wed May 22 05:08:47 EDT 2013

Powered by FUDForum. Page generated in 0.01935 seconds