Edit jar files with python

Do you know the python module with which I can add files to the JAR archive?

(what I do not want to do is add .class files to the jar archive)

and the program that needs to do this must be written in python

Thanks!

+6
source share
2 answers

.jar files are simply .zip files with a different file extension and manifest.

Try http://docs.python.org/library/zipfile.html

+10
source

This can be done using subprocess calling the jar command:

import subprocess def add_to_jar(file2add, jar_file): cmd = 'jar -uf ' + jar_file + " " + file2add proc = subprocess.Popen(cmd, shell=True) add_to_jar(file_to_add, jar_file) 
0
source

Source: https://habr.com/ru/post/894743/


All Articles