If you want to execute some piece of python script code in your java programm, you may have two good options to achieve this.
One is "javax.script" , the other is "jython"
Both of them could open a python intepreter in your programm, and execute python script.
1. javax.script
2 Jython
jython is java implementation of python. In this approach, you need to install jython, then from the build package, find out jython.jar.
Import this jar to your project. We need to use classes e.g "org.python.util.PythonInterprete" in this jar.
See also : http://jythonpodcast.hostjava.net/jythonbook/chapter10.html
3. If you just want to execute a python script file. You can use Runtime.exec() to fork a process and execute the command.
The key point of these approach is "Set correct environment variables to JVM"
Below is a example.
What's more in this example? Standard output stream - stdout in python script will be redirect to java inputstream, this is extremly
useful when you want to retrieve data / check the result from the python script.