8

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-INF directory

META-INF > somefolder > somefile

evan
  • 1,120
  • 4
  • 13
  • 32

6 Answers6

14
jar uf jarfile.jar META-INF/somefolder/somefile
dogbane
  • 266,786
  • 75
  • 396
  • 414
2

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.

thejh
  • 44,854
  • 16
  • 96
  • 107
2

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

Jeff Swensen
  • 3,513
  • 28
  • 52
2

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.

Roman Goyenko
  • 6,965
  • 5
  • 48
  • 81
2

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.

aioobe
  • 413,195
  • 112
  • 811
  • 826
1

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/
mrts
  • 16,697
  • 8
  • 89
  • 72