how to add files to jars META-INF
i want to create a jar file in which i want to place some file in the META-INF folder of the jar file.is it possible ? .i know how to create a jar file but clueless about how to put files inside META-INF
below is my desired jar files META-I开发者_运维技巧NF directory
META-INF > somefolder > somefile
jar uf jarfile.jar META-INF/somefolder/somefile
Rename the .jar
-file to something ending with .zip
, open it with an appropriate program, change what you want to change, save it and rename it back to .jar
. Jarfiles are Zipfiles.
From the jar documentation:
Updates an existing file jarfile (when f is specified) by adding to it files and directories specified by inputfiles. For example: jar uf foo.jar foo.class
You probably have the META-INF folder already when you create the jar from the source. Just put your files there before making the jar.
Try creating a META-INF
directory among the .class-files that you want to be included in the jar. Put whatever you want in this META-INF
directory, and it will be included in the compiled jar-file.
Here's how to create a JAR with a custom folder somefolder
under META-INF
:
mkdir META-INF
cp -a somefolder META-INF
jar cvf jarfile.jar META-INF/
精彩评论