I am trying to execute a python script from within a Java program. I know that one of the way to do that is through the use of Runtime.getRuntime().exec()
but the issue with this approach is that each time we use it we fork a new Process
and hence I want to explore some other way also.
I want to use jython
but I am unable to get an example which shows to do so. The examples which I saw were executing individual python commands but I want to execute the whole script at once just like we do it in Runtime.getRuntime().exec()
but instead I want to do it through jython
. Is there a way to do so? If there is any way then please provide me a simple example so that I can understand it.