This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unable to pass argument to python script from Java program
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Bhupesh Rathod, r.david.murray
Priority: normal Keywords:

Created on 2015-07-08 05:35 by Bhupesh Rathod, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg246449 - (view) Author: Bhupesh Rathod (Bhupesh Rathod) Date: 2015-07-08 05:35
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();
		}
	}
msg246456 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-07-08 13:06
For help with programming, please try the python-list mailing list, or in this case probably a java forum.  If you find that there is really is a bug (this is very unlikely) you can reopen this issue with more information about the problem you found.
History
Date User Action Args
2022-04-11 14:58:18adminsetgithub: 68776
2015-07-08 13:06:28r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg246456

resolution: not a bug
stage: resolved
2015-07-08 05:35:53Bhupesh Rathodcreate