简体   繁体   中英

Run Jython code from java class

I am working on executable jar file that will run jython file to get some result. I tried calling jython file through this technique.

Run .bat file from java class and that .bat file will call Jython file.

Runtime rt = Runtime.getRuntime();
Process process = rt.exec(new String[] { "cmd.exe", "/c", "D:\\calljython.bat " + parameters + "" });

After jython file runs I read output through InputStream and get results. This technique works file when run from eclipse but fails when executable jar is created and run.

Another thing I use is PythonInterpreter but also face problems in this case.

What I want to do is:

Run Jython code from java along with parameters to be used in Jython file and get result.

Try debugging code and make sure that bat file or jython are being called and returning results. bat file should places along-with jar file you are executing (same hierarchy).

Runtime rt = Runtime.getRuntime();
Process process = rt.exec(new String[] { "cmd.exe", "/c", "calljython.bat " + parameters + "" });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM