[New-bugs-announce] [issue24588] Unable to pass argument to python script from Java program
Bhupesh Rathod
report at bugs.python.org
Wed Jul 8 07:35:53 CEST 2015
New submission from Bhupesh Rathod:
I have following java method
It makes call to python scripts
I am unable to pass arguments using "engine.put(ScriptEngine.ARGV, strArg);"
I have JDK 8 on windows system
code as follows
/****************************************************/
public static void execute()
{
StringWriter writer = new StringWriter(); //to store output
ScriptEngineManager manager = new ScriptEngineManager();
ScriptContext context = new SimpleScriptContext();
context.setWriter(writer); //configures output redirection
ScriptEngine engine = manager.getEngineByName("python");
String strPath = "C:\\Bhupesh\\Data\\script";
try {
Reader reader = new FileReader(strPath+"\\"+"numbers.py");
String[] strArg = {"1", "78"};
engine.put(ScriptEngine.ARGV, strArg);
engine.eval(reader, context);
reader.close();
} catch (ScriptException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
----------
messages: 246449
nosy: Bhupesh Rathod
priority: normal
severity: normal
status: open
title: Unable to pass argument to python script from Java program
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24588>
_______________________________________
More information about the New-bugs-announce
mailing list