0

I have a python script and need to run the python script from Java. How to do this?

2
  • 2
    Welcome 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. Commented Sep 24, 2012 at 8:59
  • @SAJ: The above comment looks like sarkasm, but it is well intended ;) Commented Sep 24, 2012 at 9:37

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

Comments

1
Runtime.getRuntime().exec("python script_name.py") 

Comments

1

In addition to jython, python.org lists also Jepp as a possible choice.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.