How to execute an external program
ipc, java, python
Solution
use cwd parameter
subprocess.Popen(["java -mx256m -jar ../sphinx4-1.0beta5/bin/HelloWorld.jar"], cwd=r'path', shell=True)
http://docs.python.org/2/library/subprocess.html "If cwd is not None, the child’s current directory will be changed to cwd before it is executed. Note that this directory is not considered when searching the executable, so you can’t specify the program’s path relative to cwd."
Problem
I'm trying to execute a java program from a python program : ``` subprocess.Popen(["java -mx256m -jar /sphinx4-1.0beta5/bin/HelloWorld.jar"], shell=True) ``` but it fails with this error: ``` Error: Unable to access jarfile /sphinx4-1.0beta5/bin/HelloWorld.jar ``` i need to be in an specific directory : `/home/karen/sphinx4-1.0beta-src`, to execute the command:`"java -mx256m -jar /sphinx4-1.0beta5/bin/HelloWorld.jar"` But i don't know how to do this. I need that my python program execute it !