如何重新编译 jar 文件?

发布于 2024-09-11 13:00:55 字数 71 浏览 2 评论 0原文

我拿了一个旧的 jar 文件并对其进行了编辑。现在我有一个包含所有文件的文件夹,我想将它们重新编译回 jar 文件。我该怎么做?

I took an old jar file and edited it. Now i have a folder that has all the files and I want to recompile them back to a jar file. How do i do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

ペ泪落弦音 2024-09-18 13:00:55

Jar 文件并不是正常意义上的“编译”。但您只需使用 jar 命令创建一个:

jar cvf myfile.jar file1 file2 etc

您可以像平常一样使用通配符:

jar cvf ../myfile.jar *

运行 jar -? 或阅读 docs 了解更多信息。

请注意,对于可执行 jar 文件,您还需要指定清单文件。

Jar files aren't "compiled" in the normal sense of the word. But you just create one with the jar command:

jar cvf myfile.jar file1 file2 etc

You can use globbing as normal:

jar cvf ../myfile.jar *

Run jar -? or read the docs for more information.

Note that for an executable jar file, you'll need to specify the manifest file as well.

请帮我爱他 2024-09-18 13:00:55

你是怎么编辑的?

无论如何,jar 文件遵循与常规 zip 文件相同的格式。如果您想更新 jar 的内容(可能使用新文件),您可以这样做:

jar -uf yourJar.jar  path/to/updated/Class.class 

这将使用文件 path/to/updated/Class.class 更新您的 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.

羅雙樹 2024-09-18 13:00:55

Jar 文件通常包含已编译的 java 文件(类文件)和资源。
如果您被允许对此 jar 进行更改,则可以使用 JAD 反汇编类文件并在重新编译后使用命令 jar

你是如何编辑 jar 文件的,十六进制编辑器?

Jar files usually contain compiled java files (class-files) and resources.
If you are allowed to make changes on this jar, you could disassemble the class files using JAD and after recompilation assemble them again with the command jar

How did you edit a jar file, hex editor?

把时间冻结 2024-09-18 13:00:55

jar 文件只是带有一些额外文件的 zip 文件。您可以使用任何 zip 实用程序重新打包未打包的 jar 文件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文