Java 我应该如何编辑 jar 的清单?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18381847/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 01:04:23  来源:igfitidea点击:

How should i edit manifest for jar?

javamysqljarappletmanifest

提问by krotovic

I create an application - Instant Messenger - with connecting to MySQL and it required MySQL Driver, so I enclose this external library and this program works well. But I'd like to re-create this app as Applet and archive it to .jar How could I edit manifest for enclosing the Driver to Applet?

我创建了一个应用程序 - Instant Messenger - 连接到 MySQL 并且它需要 MySQL 驱动程序,所以我附上了这个外部库,这个程序运行良好。但我想将此应用程序重新创建为 Applet 并将其存档到 .jar 如何编辑清单以将驱动程序封装到 Applet?

I know I can use (for desktop app) Class-Path: external.jar but does it work for applets either?

我知道我可以使用(对于桌面应用程序)Class-Path: external.jar 但它也适用于小程序吗?

Thanks for all.

谢谢大家。

EDIT: Or is there another way how to enclose external jar to an Applet? E.g. with HTML code?

编辑:或者有另一种方法如何将外部罐子封装到小程序?例如使用 HTML 代码?

回答by Nick Holt

If you're using the command line, then just typing jarprints this:

如果您使用命令行,则只需键入即可jar打印:

enter image description here

在此处输入图片说明

Example 2 allows you to specify the file that will be used as the manifest.

示例 2 允许您指定将用作清单的文件。

回答by Amin Rezapour

An easier way to edit a manifest file inside a JAR file is as follows:

在 JAR 文件中编辑清单文件的更简单方法如下:

  • change the extension of your JAR file to ZIP, e.g. test.jar just rename it to test.zip
  • unzip your file
  • edit your manifest file using a text editor, e.g. notepad++
  • zip the contents of the unzipped folder
  • rename it to test.jar
  • 将 JAR 文件的扩展名更改为 ZIP,例如 test.jar 只需将其重命名为 test.zip
  • 解压缩你的文件
  • 使用文本编辑器编辑您的清单文件,例如记事本++
  • 压缩解压文件夹的内容
  • 将其重命名为 test.jar