From: Sebastien D. <sde...@ve...> - 2001-11-09 18:31:40
|
Hi, I have a very dummy Jython script, except.py, that does : except.py : 1: import java.lang.Exception 2: raise java.lang.Exception I then compile this to a standalone jar (jythonc --core --jar except.jar except.py), that I call from another Java class; the call itself looks like : try { String jar = "./except.jar"; URLClassLoader theLoader = new URLClassLoader(new URL[] { new URL("file:" + jar)}); Object theLoadedClass = Class.forName("except", true, theLoader).newInstance(); String[] array = new String[] {}; Method main = theLoadedClass.getClass(). getMethod("main", new Class[] { array.getClass() }); main.invoke(theLoadedClass, new Object[] {new String[] {}}); } catch (Throwable t) { t.printStackTrace(); } The problem is that my "catch" actually doesn't catch the Exception I'm throwing/raising from the jython script. On the other hand, I believe my Java call to execute the jar is legal, since if I do : except.java : 1: import java.lang.Exception; 2: public class except { 3: public static void main(String[] args) throws Exception { 4: throw new Exception(); 5: } 6: } and compile/jar that class into except.jar, then the exception is caught. Thanks for any input, since I seem to be missing something obvious : I just would like to be able to catch the exceptions raised from the python script, in the java caller. I'm sure that's doable :) --Sebastien ============================================================================ This message is intended only for the use of the Addressee(s) and may contain information that is PRIVILEGED and CONFIDENTIAL. If you are not the intended recipient, dissemination of this communication is prohibited. If you have received this communication in error, please erase all copies of the message and its attachments and notify pos...@ve... immediately. ============================================================================ |