From: Ype K. <yk...@xs...> - 2002-02-17 19:32:16
|
Branko, >Thanks Ype, > >Now when I know what to do I still can't pull it off...maybe I overlooked >something since I want to get this "baby" started ASAP: > >Q1: How do I set sys.path in my java code? >The solution posted on FAQ pages doesn't seem to work: > >Properties props = new Properties(); > props.setProperty("python.path", "path to my modules"); > PythonInterpreter.initialize(System.getProperties(), props, > new String[] {""}); >Q2: How do I populate/set sys.argv for myapp.py in my java code? Inserting '.' in front of sys.path from java: interpr.exec("sys.path[0:0] = ['.']"); Removing it afterwards: interpr.exec("del sys.path[0]"); Basically write the wrapping code statements in jython have your interpr execute these one by one. Similar for sys.argv. In case you want to make sure sys.path is the same afterwards use try/finally in java: interpr.exec("sys.path[0:0] = ['.']"); try { interpr.exec('yourcode.py'); } finally { interpr.exec("del sys.path[0]"); } >Sorry for the newbie questions...I really appreciate your time taken to answer this. It's not newbie stuff, but it keeps popping up. Embedding jython seems to be popular these days. Regards, Ype -- |