From: <wer...@gm...> - 2007-03-08 12:34:14
|
Dear all, maybe you hav an idea what is going wrong here. I want to call Jython programs from a legacy Java application. The legacy application calls method go() in class secondexample. When I execute the program, command_1 (argument of sendCommand method) and command 2 are executed correctly. After that, the calling application blocks; so obviously the PythonInterpreter.initialize line causes the problems. The same thing happens if I directly instantiate a PythonInterpreter, e.g. like org.python.util.PythonInterpreter python = new org.python.util.PythonInterpreter(); instead of the PythonInterpreter.initialize statement. The same code executed in the main method, however, works correctly with the expected result. Do you have any idea what might go wrong when the interpreter is initialized inside the go() method? Thanks a lot for any hint. Kind regards Markus package org.epo.mr50032; import org.epo.epoque.preparation.*; import java.awt.*; import org.python.util.*; import org.python.core.*; import java.util.*; public class secondexample extends AbstractUserPreparation //This is one of the imported classes { public void go() { sendCommand(command_1); PythonInterpreter interp; Properties props=new Properties(); String []args1 = new String[1]; props.setProperty("python.home","c:\\Documents and Settings\\MR50032\\jython_2.1"); sendCommand(command_2); PythonInterpreter.initialize(System.getProperties(),props,args1); sendCommand(command_3); } public static void main(String[] args) { System.out.println("Hello World!"); // Display the string. PythonInterpreter interp; Properties props=new Properties(); props.setProperty("python.home","c:\\Documents and Settings\\MR50032\\jython_2.1"); PythonInterpreter.initialize(System.getProperties(),props,args); interp = new PythonInterpreter(); interp.exec("import sys"); interp.exec("print"); // Add empty line for clarity interp.exec("print 'sys.prefix=', sys.prefix"); interp.exec("print 'sys.argv=', sys.argv"); interp.exec("print 'sys.path=', sys.path"); interp.exec("print 'sys.cachedir=', sys.cachedir"); interp.exec("print"); // Another blank for clarity } } -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer |