我拿了一个旧的 jar 文件并对其进行了编辑。现在我有一个包含所有文件的文件夹,我想将它们重新编译回 jar 文件。我该怎么做呢?
4 回答
Jar 文件不是正常意义上的“编译”。但是您只需使用以下jar
命令创建一个:
jar cvf myfile.jar file1 file2 etc
您可以正常使用通配符:
jar cvf ../myfile.jar *
运行jar -?
或阅读文档以获取更多信息。
请注意,对于可执行 jar 文件,您还需要指定清单文件。
How did you edit it?
Anyway, jar
files follow the same format as regular zip
files. If you want to update the content of the jar ( probably with a new file ) you could do:
jar -uf yourJar.jar path/to/updated/Class.class
That would update your jar with the file path/to/updated/Class.class
If there's already a class with that name in that path, it would be replaced. If is not it would be created.
After this your jar is up to date.
A jar file is just a zip file with a few extra files. You Can use any zip utility to rejar an unjarred jar file.