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

3
  • Its java question or python ? Commented Feb 27, 2014 at 17:10
  • 1
    Like any other shell command. stackoverflow.com/questions/89228/… Commented Feb 27, 2014 at 17:13
  • @DevEx I think others might find this question via google, so I answered it below. Does that resolve your problem? Commented Feb 27, 2014 at 17:51

1 Answer 1

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"])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.