On Tue, 11 Mar 2008, Bill Janssen wrote:
Sadly, the classpath additions don't seem to stick so it must be set either
in the environment or via the classpath keyword to initVM().
Have you seen this code, from
<http://forum.java.sun.com/thread.jspa?threadID=300557&start=45&tstart=0>?
No, but if this works I could compile into JCC by default when --shared is
true to make env->setClassPath() work.
Interesting, thanks for the link.
Andi..
Bill
-------------
import java.lang.reflect.*;
import java.io.*;
import java.net.*;
public class ClassPathHacker{
private static final Class[] parameters = new Class[]{URL.class};
public static void addFile(String s) {
File f = new File(s);
addFile(f);
}
/* File.toURL() was deprecated, so use File.toURI().toURL() */
public static void addFile(File f) {
try {
addURL(f.toURI().toURL());
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void addURL(URL u) {
URLClassLoader sysloader =
(URLClassLoader)ClassLoader.getSystemClassLoader();
try {
/* Class was uncheched, so used URLClassLoader.class
instead */
Method method =
URLClassLoader.class.getDeclaredMethod("addURL",parameters);
method.setAccessible(true);
method.invoke(sysloader,new Object[]{u});
System.out.println("Dynamically added " + u.toString() + "
to classLoader");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev