Zenvega
Zenvega

Reputation: 2054

python: calling java program

I have a tag cloud generator that I would like to call from my python program. How can I do it?

I run it in a batch file

java -jar ibm-word-cloud.jar -C configure.txt input.txt output.png

thanks for your help.

Upvotes: 2

Views: 1731

Answers (2)

GreenMatt
GreenMatt

Reputation: 18570

The subprocess module is now preferred over os.system(). A simple example, assuming run_prog.bat contains the command you need:

import subprocess
cmd = "run_prog.bat"
proc = subprocess.Popen(cmd)

Upvotes: 3

jle
jle

Reputation: 9479

You can use the os module:

import os
os.system('mybatchfile.bat')

or use the subprocess module

Upvotes: 2

Related Questions