开发者

Problem when packaging using jar

I try to use jar command to pack a bunc开发者_如何学Goh 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜