skyork
skyork

Reputation: 7401

Problem when packaging using jar

I try to use jar command to pack a bunch of java class files and images that are used by them. I have .class files in two folders (packages): a and b, and all the images in folder c. I also have a manifest.mf file in META-INF folder, and inside manifest.mf I specify the main class when launching the jar file. I use the following jar command:

jar cvf MyJar.jar a b c META-INF

But the output MyJar.jar simply doesn't run at all. Did I miss anything? Thanks!

Upvotes: 0

Views: 199

Answers (1)

Thilo
Thilo

Reputation: 262734

It seems that manifest files need to be handled with a special parameter:

If you have a pre-existing manifest file that you want the jar tool to use for the new jar archive, you can specify it using the -m option:

 % jar cmf myManifestFile myJarFile *.class

So, in your case

% jar cvmf META-INF/manifest.mf MyJar.jar a b c META-INF

If you do not need the META-INF anymore (for other files in there), I'd drop it to be on the safe side.

Upvotes: 1

Related Questions