Colleagues want to write the packaging tools under the Android platform and encounter the problem of merging multiple jars into one jar. Here is a list of the steps to proceed:
1. Copy all jar files to a temporary directory and extract all the. class files through the jar command
> JAR-XVF Xx.jar
Xx.jar must be a specific jar, cannot be *.jar, will be reported FileNotFoundException
2. Delete all jar files in temp directory
> del/f *.jar
3. Merge all. class files to the jar, you need to switch to the temp directory, otherwise the generated jar will contain the temp directory
> JAR-CVFM Game.jar.
The jar command does not support "extracting" resources into the specified directory, so use the above method. However, when generating the final jar, I encountered a very deceptive place, using Jd-gui.exe to view the directory structure in the jar, and found that it would carry the "drive letter: Temporary directory" layer, no matter how I adjust the command, drag the jar into the look, it comes with the directory. Finally let the other use the same command in his machine test found that there is no problem, and finally I restarted jd-gui.exe again to see the previous generated jar discovery is normal.
More about jar-related commands can be parameters here:
Jar Command &jar Package detailed >>
Merge operations for multiple jars