Is it possible (and how) to use the beanshell classloader?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Is it possible (and how) to use the beanshell classloader?

Chris
Hello

I love beanshell and use it a lot. For the moment I am ebedding benashell and use compiled commands. Since my compiled commands use libs that are in the classpath for the beanee but not in the classpath of the beanshell binary, I catch a ClassNotFound Exception. So I thought I can use the beanshell ClassLoader like this:

public static void main(String[] args) {
    bsh.Interpreter i = new bsh.Interpreter();
    i.getClassManager().addClassPath(new URL("http://very/far/url/"));
   
    Thread.currentThread().setContextClassLoader(i.getClassManager().getClassLoader())
    i.eval("//do  cool stuff");
}

Seems the getClassLoader() method is not defined. Is there a way to get the classloader?

Thanks
Chris

PS I am embeding Beanshell into a database application using pl/java. This means I do not have any way to configure the jvms classpath to includ 3rd party libs beside the bsh.jar