I am trying to open a JAR file from python and running into problems. I am using..
import os
os.system(r"X:\file.jar")
it appears to open the window then it shuts right away, I know I am missing a simple command but not sure what it is, thanks for the help
Do you want to execute code from .jar, or open it?
If open, then .jar
file is the same format as .zip
files and you can use zipfile
module to manipulate it. Example:
def show_jar_classes(jar_file):
"""prints out .class files from jar_file"""
zf = zipfile.ZipFile(jar_file, 'r')
try:
lst = zf.infolist()
for zi in lst:
fn = zi.filename
if fn.endswith('.class'):
print(fn)
finally:
zf.close()
If you want to execute it then I prefer creating simple batch/shell script which execute java
with some parameters like -Xmx
and with environment settings required by application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With