Raed K Hakim
Raed K Hakim

Reputation: 63

Python Using Jar File

I'm trying to use a jar file in python using the library os.

I succeeded to run the jar file without a problem using the function os.system()

my command was like this:

cmd = "java -jar ./scripts/my_jar/users.jar"
os.system(cmd)

I would like to ask:

  1. do I need to kill the process (the jar file)?
  2. or python will kill the jar file automatically after the termination of the python file??

Upvotes: 0

Views: 297

Answers (1)

twiddler
twiddler

Reputation: 588

You shouldn't need to kill the jar file independently of the python program, at least with os.system. After the python program is terminated (you stop the process forcefully) the jar file will also terminate. Note, however, that if you prematurely kill/stop the python file, the jar will be forced to terminate without returning an output.

  1. python will kill the jar file automatically after the termination of the python file

Upvotes: 1

Related Questions