text: :
  > My scripts file are packaged into .jar file,how
  to load >script with the source() method
  >in this case? I tried with the following method but
  not success.
  > URL url =
  >getClass().getResource("/org/laniqi/test.script");
  > Interpreter i = new Interpreter();
  > try{
  > i.source( url.getFile() );
  > }catch(EvalError e1){
  > ... ...
  > }
  > Is there any methods to resolve this problem?
  If the >source method can accept URL
  >params, that will be great!
  >
  > Thanks,
  > Karl.
  Use:
  java.io.BufferedReader brin =
  new java.io.BufferedReader(
  new
  java.io.InputStreamReader(url.openStream(),"UTF-8")
  );
  Object o = i.eval(brin);
  I have some methods I use which let me pass a String
  and the code figures out if it's a URL and is a starts
  with file: or new File(value).exists() then do source
  other wise see if it's a URL and can open with new
  URL(value).openStream() and use eval. It makes it a
  little more flexible.
  Wade
  I think I have written on this subject before, and if
  so then apologies. I've seen messages about this
  before with no definitive answers. The main issue is
  this. I can run scripts and access my class package
  fine from the Thread running the servlet request (in
  this case Axis web service, but no mistake we're still
  dealing with a servlet call). I have one service
  which creates separate threads to process data and
  uses checks from another service to allow the client
  to later check on the status of this long running
  operation. The bsh.Interpreter instances from this
  separate thread keep throwing Class "blah blah" not
  found in namespace errors. I tracked the issue down
  to the lines:
  if ( clas == null )
  throw new ClassNotFoundException(
  "Class: " + value+ " not found in namespace");
  In Name.java of bsh.Name and all I can come up with is
  that for some reason the Interpreter is breaking in
  this threaded environment. I'm not exactly sure why
  as I can dynamically create instances of classes using
  Class.forName from this thread, so I'm trying to
  figure out if anyone has any ideas (maybe something I
  can't see in the code which occurs in threaded
  situations that someone knows about). In both cases
  where I'm calling it from the servlet thread and this
  extra thread I'm instantiating bsh.Interpreter, not
  setting a class loader, and passing script file paths.
  The bsh jar is in my WEB-INF/lib directory.
  Thanks,
  Wade
  I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details