Java 如何在我的 JNLP 应用程序中修复“缺少代码库、权限和应用程序名称清单属性”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19659134/
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
How do I fix "missing Codebase, Permissions, and Application-Name manifest attribute" in my JNLP app?
提问by ryvantage
With the recent Java updates, many people are having trouble with their Java Web Start apps lacking Codebase
, Permissions
, and Application-name
manifest attributes. Although there are resources out there to help you accomplish this, I couldn't find any comprehensiveanswers to this question, I so I felt a Q-and-A would be good. So, here's the question:
随着最新的Java更新,很多人都与他们的Java Web Start的麻烦应用缺乏Codebase
,Permissions
和Application-name
清单属性。尽管有一些资源可以帮助您完成此任务,但我找不到此问题的任何全面答案,因此我觉得问答会很好。那么,问题来了:
My Java Web Start app displays the following warnings in the console:
我的 Java Web Start 应用程序在控制台中显示以下警告:
Missing Permissions manifest attribute for: http://www.codebase.com/myApp/dist/myApp.jar
Missing Codebase manifest attribute for: http://www.codebase.com/myApp/dist/myApp.jar
Missing Application-Name manifest attribute for: http://www.codebase.com/myApp/dist/myApp.jar
How do I fix this?
我该如何解决?
采纳答案by ryvantage
(1)First, you need to create a text file with all of the attributes you want to add. My text file looks like this:
(1)首先,您需要创建一个包含要添加的所有属性的文本文件。我的文本文件如下所示:
Permissions: all-permissions
Codebase: http://www.codebase.com/myApp/dist
Application-Name: My Application
I named it addToManifest.txt
. Obviously, you'll need to change the parameters to match your application's needs.
我给它起了名字addToManifest.txt
。显然,您需要更改参数以满足应用程序的需求。
(2)Next, you need to add this to the main .jar and all of the libraries as well. The command to do this is:
(2)接下来,您需要将其添加到主 .jar 和所有库中。执行此操作的命令是:
jar ufm dist\myApp.jar addToManifest.txt
of course dist\myApp.jar
will need to point to whatever your main .jar is. You'll also need to do this for all of the libraries as well.
当然dist\myApp.jar
需要指向您的主要 .jar 文件。您还需要为所有库执行此操作。
jar ufm dist\lib\jcommon-1.0.16.jar addToManifest.txt
jar ufm dist\lib\jfreechart-1.0.13.jar addToManifest.txt
jar ufm dist\lib\joda-time-2.2.jar addToManifest.txt
...
(Note: on Windows, I wrote a .bat
file for this.)
(注意:在 Windows 上,我为此编写了一个.bat
文件。)
Once you do this, the attributes should be written to the .jar
s. You can open the .jars in a zip manager (like 7-Zip), extract the MANIFEST.MF
file, open it in a text editor, and you should see the attributes listed.
执行此操作后,应将属性写入.jar
s。您可以在 zip 管理器(如 7-Zip)中打开 .jars,提取MANIFEST.MF
文件,在文本编辑器中打开它,您应该会看到列出的属性。
(3)After adding the attributes, you need to resign your app. The command to do that is:
(3)添加属性后,您需要退出您的应用程序。执行此操作的命令是:
jarsigner dist\myApp.jar -keystore "C:\myApp\KEYSTORE.ks" alias -storepass password
You'll also need to do this for all of your libraries as well:
您还需要为所有库执行此操作:
jarsigner dist\lib\jcommon-1.0.16.jar -keystore "C:\myApp\KEYSTORE.ks" alias -storepass password
jarsigner dist\lib\jfreechart-1.0.13.jar -keystore "C:\myApp\KEYSTORE.ks" alias -storepass password
jarsigner dist\lib\joda-time-2.2.jar -keystore "C:\myApp\KEYSTORE.ks" alias -storepass password
After that, your attributes should be added and your .jar
s should be signed!
之后,你的属性应该被添加,你的.jar
s 应该被签名!
NOTE: You only need to sign/deploy your libraries once unless you are changing the library structure. i.e., if you are updating your app but the libraries have already had their manifests altered, signed properly, and deployed, you won't need to resign/deploy the libraries unless you are adding/removing libraries from your app.
注意:除非您要更改库结构,否则您只需签署/部署您的库一次。即,如果您正在更新您的应用程序,但库已经更改、正确签名和部署了它们的清单,则除非您要从应用程序中添加/删除库,否则您无需重新签名/部署这些库。
NOTE #2: The current version of Netbeans will add Codebase
and Permissions
manifest attributes to your primary .jar only, but not to your libraries. If you use Netbeans, you will receive a warning from the jar
utility when you try to add a duplicate manifest attribute. There is a bug report in the queue to have this fixed https://netbeans.org/bugzilla/show_bug.cgi?id=234231.
注2:Netbeans的当前版本将添加Codebase
和Permissions
清单属性您主要的.jar只,而不是你的库。如果您使用 Netbeans,jar
当您尝试添加重复的清单属性时,您将收到来自实用程序的警告。队列中有一个错误报告来修复这个https://netbeans.org/bugzilla/show_bug.cgi?id=234231。
EDIT: The latest version of Netbeans (8.0) now adds all three (Codebase
, Permissions
, and Application-Name
) to the manifest for you.
编辑:Netbeans的(8.0)的最新版本现在增加了三个(Codebase
,Permissions
,和Application-Name
)的清单给你。
回答by Atul Soman
Another way could be to handle it in your build script itself.
另一种方法可能是在您的构建脚本中处理它。
Step 1: Define a target to update
第 1 步:定义要更新的目标
<target name="updateManifest">
<manifest file="${file}" mode="update">
<attribute name="Trusted-Only" value="true"/>
<attribute name="Permissions" value="all-permissions"/>
<attribute name="Codebase" value="*"/>
</manifest>
</target>
Step 2: Call the update target and use the new manifest in jar
第 2 步:调用更新目标并使用 jar 中的新清单
<ant target="updateManifest">
<property name="file" location="manifest.use" />
</ant>
<jar jarfile="${jar_name}.jar" manifest="manifest.use">
<fileset dir="${dest}">
<include name="File1" />
</fileset>
</jar>
回答by Atul Soman
If the error message looks like this:
如果错误消息如下所示:
Missing Application-Name manifest attribute for: server root/filename.jar
You can solve it this way:
你可以这样解决:
Start
control panel
Choose
Java Control Panel
Select
Security
tabAt
Exception Site list
click onEdit Site List
buttonClick on
Add
button.Type the server root (eg.:https://ibank.cib.hu), and press
OK
Restart your browser/application.
开始
control panel
选择
Java Control Panel
选择
Security
标签在
Exception Site list
点击Edit Site List
按钮单击
Add
按钮。输入服务器根目录(例如:https: //ibank.cib.hu),然后按
OK
重新启动浏览器/应用程序。
回答by gouessej
If you use Netbeans, set those attributes in your file nbproject/project.properties:
如果您使用 Netbeans,请在文件 nbproject/project.properties 中设置这些属性:
- manifest.custom.codebase
- manifest.custom.permissions
- manifest.application.name.attribute
- manifest.custom.codebase
- manifest.custom.permissions
- manifest.application.name.attribute
The very last one is supported only by Netbeans >= 8.0 (see here). The others should work even in Netbeans 7.2. I set jnlp.mixed.code to trusted_only too but maybe it isn't appropriate in your case. You can modify your file jnlp-impl.xml at your own risk if you can't switch to a more recent version of Netbeans.
最后一个仅由 Netbeans >= 8.0 支持(请参阅此处)。其他的应该甚至在 Netbeans 7.2 中工作。我也将 jnlp.mixed.code 设置为 trust_only 但可能不适合您的情况。如果您无法切换到更新版本的 Netbeans,您可以自行承担风险修改文件 jnlp-impl.xml。
atulsm's suggestion is better if you don't use Netbeans.
如果您不使用 Netbeans,atulsm 的建议会更好。
回答by nikli
Sample for adding manifest
to jar and signing jars..
添加manifest
到 jar 和签名 jar 的示例..
<target name="-post-compile">
<jar destfile="${build.web.dir}/jars/app.jar" >
<fileset dir="${build.classes.dir}">
<include name="com/sample/test/client/**/*.*"/>
<include name="com/sample/test/share/**/*.*"/>
</fileset>
<manifest>
<attribute name="Author" value="${user.name}"/>
<attribute name="Permissions" value="all-permissions"/>
<attribute name="Codebase" value="http://localhost:8080/app/"/>
<attribute name="Application-Name" value="App"/>
</manifest>
</jar>
<signjar keystore="app.keystore" storepass="test" jar="${build.web.dir}/jars/app.jar" alias="tomcat" />
<copyfiles files="${file.reference.javadatepicker.jar}" todir="${build.web.dir}/jars"/>
<delete dir="${build.web.dir}/WEB-INF/classes/com/sample/app/client"/>
<!--keytool -genkey -alias tomcat -keystore app.keystore -keypass test -storepass test -validity 1960-->
<signjar keystore="app.keystore" storepass="test" jar="${build.web.dir}/jars/javadatepicker.jar" alias="tomcat" />
</target>