I have a python script and need to run the python script from Java. How to do this?
- 2Welcome to Stack Overflow! We encourage you to research your questions. If you've tried something already, please add it to the question - if not, research and attempt your question first, and then come back.user647772– user6477722012-09-24 08:59:24 +00:00Commented Sep 24, 2012 at 8:59
- @SAJ: The above comment looks like sarkasm, but it is well intended ;)pepr– pepr2012-09-24 09:37:05 +00:00Commented Sep 24, 2012 at 9:37
Add a comment |
3 Answers
One option is to use jython (Python written in Java).
If that's not appropriate, you can fork/exec your script process using Runtime.exec(). Using this can be a bit fiddly, however - check out this article for common gotchas.
Comments
In addition to jython, python.org lists also Jepp as a possible choice.
1 Comment
Colin O'Coal
I think JPype isn't here the right choice. JPype is "Java in Python", not "Python in Java". But Jepp (jepp.sourceforge.net) would be work like expected.