如何重新编译 jar 文件?
我拿了一个旧的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Jar 文件并不是正常意义上的“编译”。但您只需使用
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:You can use globbing as normal:
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.
你是怎么编辑的?
无论如何,
jar
文件遵循与常规zip
文件相同的格式。如果您想更新 jar 的内容(可能使用新文件),您可以这样做:这将使用文件
path/to/updated/Class.class
更新您的 jar 如果已经有一个类在该路径中使用该名称,它将被替换。如果不是,它将被创建。在此之后,您的罐子就是最新的。
How did you edit it?
Anyway,
jar
files follow the same format as regularzip
files. If you want to update the content of the jar ( probably with a new file ) you could do: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.
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?
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.