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
  • 4,337
  • 13
  • 46
  • 68

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
  • 13,012
  • 16
  • 70
  • 120