1

I am a beginner in Python and I need to call .py script from Java code. I have installed jython but the tutorials I am getting online has material where they are importing Java packages in Python code. But my query is the other way round.

I just need a simple code in Java which is able to run Python scripts(.py).

Any leads will be highly appreciated.

1
  • just search on google "call .py script from java code" and get the answer Process p = Runtime.getRuntime().exec("python yourapp.py"); Mar 20, 2018 at 8:56

1 Answer 1

1

Use jython library or run in CMD:

String command = "python script.py";
Process p = Runtime.getRuntime().exec(command);

Not the answer you're looking for? Browse other questions tagged or ask your own question.