Utilities to help with Java development and deployment
Python class to parse Java jar files
Constructor for Jar class. jarfile can be a string pathname or a file object
Retrieves the jar file entry name as a file object
Returns a list of entries in the jar file that match the given regular expression
Returns the jar manifest entries as a dictionary
Python script to look inside an executable jar file, parse out its
classpath, optionally use any embedded pom.xml
files to resolve jar dependencies, and then make symbolic links for all the dependencies in the classpath pointing to the local on-disk maven repository jars.
$ python getJars.py [-r] jar-file
where -r means do maven dependency resolution first
What this script does is the following:
- If the
-r
flag is specified, it finds thepom.xml
file in the jar file, and does amvn dependency:resolve
on the pom file, which downloads all the dependencies into the local Maven repository (usually located in~/.m2/repository
) - Next, it retrieves the
Class-Path
entry from the jar'sMETA-INF/MANIFEST.MF
file, and looks for each entry in the local Maven repository - For each jar file dependency it finds, it creates a symbolic link from the value specified in the manifest class path, pointing to the actual jar file in the Maven repository
Thus, assuming all dependencies are resolved and found, your executable jar file should be have all its dependencies resolved, and should run with java -jar jar-file
.