1

How can I call this jar from python and also capture the results:

c:> java -cp "C:\mallet-2.0.7\class;C:\mallet-2.0.7\lib\mallet-deps.jar" cc.mallet.fst.SimpleTagger --model-file nouncrf sample.txt

DevEx
  • 3,247
  • 10
  • 37
  • 57

1 Answers1

1

Use subprocess:

from subprocess import call
call(["java", "-jar", "foo.jar"])

You could also add other arguments like -cp to the list:

call(["java", "-cp", "<yourclasspath>", "-jar", "foo.jar"])
Uli Köhler
  • 11,813
  • 14
  • 55
  • 105