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.

Author Bhupesh Rathod
Recipients Bhupesh Rathod
Date 2015-07-08.05:35:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1436333753.46.0.248622877126.issue24588@psf.upfronthosting.co.za>
In-reply-to
Content
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();
		}
	}
History
Date User Action Args
2015-07-08 05:35:53Bhupesh Rathodsetrecipients: + Bhupesh Rathod
2015-07-08 05:35:53Bhupesh Rathodsetmessageid: <1436333753.46.0.248622877126.issue24588@psf.upfronthosting.co.za>
2015-07-08 05:35:53Bhupesh Rathodlinkissue24588 messages
2015-07-08 05:35:52Bhupesh Rathodcreate