Hi,
I think I've solved the problem in a way that I don't like...
Code:
File baseFile = new File(baseFileName);
// Then, load additional libraries into SYSTEM CLASSLOADER'S CLASSPATH
String classPathString = baseFile.getParent();
File oooClassPath = new File(classPathString);
File[] files = oooClassPath.listFiles();
int count = 0;
int i;
for (i = 0; i < files.length; i++) {
try {
String name = files[i].getAbsolutePath().toUpperCase();
if (name.endsWith(".JAR") && !name.equalsIgnoreCase(baseFileName)) {
ClassPathHacker.addFile(files[i]);
System.out.println(files[i].getAbsolutePath());
}
} catch (MalformedURLException ex) {
System.out
.println("ClassManager.getURLClassLoader - in for loop, MalformedURLException: "
+ ex.getMessage());
} catch (IOException ex) {
System.out
.println("ClassManager.getURLClassLoader - in for loop, IOException, param: "
+ files[i].getAbsolutePath());
}
}
return (URLClassLoader) ClassLoader.getSystemClassLoader();
..and
ClassPathHacker is (I found it in Sun's website):
Code:
public class ClassPathHacker {
private static final Class[] parameters = new Class[] { URL.class };
public static void addFile(String s) throws IOException {
File f = new File(s);
addFile(f);
}// end method
public static void addFile(File f) throws IOException {
addURL(f.toURL());
}// end method
public static void addURL(URL u) throws IOException {
Class sysclass = URLClassLoader.class;
URLClassLoader sysloader = (URLClassLoader) ClassLoader
.getSystemClassLoader();
try {
Method method = sysclass.getDeclaredMethod("addURL", parameters);
method.setAccessible(true);
method.invoke(sysloader, new Object[] { u });
} catch (Throwable t) {
t.printStackTrace();
throw new IOException(
"Error, could not add URL to system classloader");
}// end try catch
}// end method
}// end class
Now I have to test it..and so I'll tell you about..
Thanks!
Regards