Java 提取并重新创建的jar不支持位于“META-INF/manifest.MF”的清单`

Java 提取并重新创建的jar不支持位于“META-INF/manifest.MF”的清单`,java,jar,Java,Jar,我试图弄清楚如何将Jython程序打包为一个独立的可运行jar,但遇到了一个奇怪的问题 mkdir /tmp/stackoverflow 以某种方式获取Jython独立jar wget http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar && mv ./*.jar ./jython-standalone-2.7.

我试图弄清楚如何将Jython程序打包为一个独立的可运行jar,但遇到了一个奇怪的问题

mkdir /tmp/stackoverflow
以某种方式获取Jython独立jar

wget http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar && mv ./*.jar ./jython-standalone-2.7.0.jar
请注意,它在未将脚本作为命令行参数传递时运行Jython repl

java -jar ./jython-standalone-2.7.0.jar
产生:

Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) 
[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.7.0_95
Type "help", "copyright", "credits" or "license" for more information.
当我打开罐子并重新包装时,它会抱怨缺少清单

mkdir unpack
cd unpack
jar -xf ../jython-standalone-2.7.0.jar
# repack jar
jar -cvf output.jar ./*
这次
java-jar output.jar
生成以下输出

no main manifest attribute, in output.jar
事实证明,
output.jar
jython-standalone-2.7.0.jar
的内容有所不同,但我认为这正是压缩的本质

$ diff output.jar ../jython-standalone-2.7.0.jar
Binary files output.jar and ../jython-standalone-2.7.0.jar differ
但是,中包含的路径没有差异(以下命令不生成输出)


$diff事实证明,需要明确告诉
jar
在哪里查找
MANIFEST.MF
文件

jar -cvmf META-INF/MANIFEST.MF output.jar ./* 

produces a jar that can be run just like the original one. This still leaves the question of what file actually changes when a `MANIFEST.MF` file is specified as an argument.

jar -cvmf META-INF/MANIFEST.MF output.jar ./* 

produces a jar that can be run just like the original one. This still leaves the question of what file actually changes when a `MANIFEST.MF` file is specified as an argument.