java - using python subprocess to run javaw.exe -


i use javaw.exe in windows command prompt , returns after spawning swing java program.

but if use python's subprocess.call() same thing, hangs.

import subprocess retval = subprocess.call(['javaw.exe','-jar','myjar.jar',arg1,arg2]) 

what doing wrong , why there difference?

subprocess.call wait process (javaw) complete, says in docs:

run command described args. wait command complete, return returncode attribute.

you should use subprocess.popen instead.

check out docs replacing os.spawn family:

pid = os.spawnlp(os.p_nowait, "/bin/mycmd", "mycmd", "myarg") ==> pid = popen(["/bin/mycmd", "myarg"]).pid 

in case, probably

pid = subprocess.popen(["javaw.exe", "-jar", "myjar.jar", arg1, arg2]) 

perhaps adjusted absolute path javaw.exe, or shell=true, depending on mood , needs.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -