我如何注入新的清单成小应用程序的现有罐子 [英] How do I inject new manifest into an existing jar for applet

查看:143
本文介绍了我如何注入新的清单成小应用程序的现有罐子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,已经工作多年(2)。但由于新的Java限制(2014年1月),我的小应用程序将被阻止。所以,做一些阅读后,似乎一切我所要做的就是改变清单文件;我甚至都不需要重新编译code。 (如果我错了这一点,请大家指正。)

I have a website that has been working for years (2). But since the new java restrictions (January 2014), my applet is blocked. So after doing some reading, it seems all I have to do is change the manifest file; I don't even need to recompile the code. (If I am wrong about this, please correct me.)

所以,我创建了以下清单文件

So I have created the following manifest file

Manifest-Version: 1.0
Created-By: 1.7.0_51
Permissions: sandbox
Application-Name: MyFarmingBusiness
Application-Library-Allowable-Codebase:http://mycompany.com/version_4/myapplet/
Caller-Allowable-Codebase:www.mycompany.com
Codebase: www.mycompany.com

然后到清单注入到我的瓶子

Then to inject the manifest into my jar


  • 我在同一个目录中manifest.txt文件保存为罐子

  • 在随后的Mac OSX终端I型:'罐子CFM MyGreat.jar manifest.txt

其结果是,我得到以下错误

As a result, I get the following error

java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:410)
at java.util.jar.Manifest.read(Manifest.java:199)
at java.util.jar.Manifest.<init>(Manifest.java:69)
at sun.tools.jar.Main.run(Main.java:172)
at sun.tools.jar.Main.main(Main.java:1177)

有谁知道如何解决这一问题?

Does anyone know how to fix this?

另一种方法可能是重新再造的罐子。
所以我做了以下

Another approach might be to recreate the jar anew. So I did the following


  • 来提取源:罐子XF MyGreat.jar

  • 但后来,我还没有在这么长时间这样做了,我不知道如何从源头上重建的jar:源仅包含的.class 文件在目录 COM / myCompany中/...,并在一个名为 META-INF 目录清单。我尝试网上搜索,但我还没有对如何从终端。做到这一点运气

  • to extract the source: jar xf MyGreat.jar
  • but then, I haven't done this in so long, I don't know how to reconstruct the jar from the source: the source only contains .class files in directory com/mycompany/... and the manifest in a directory called META-INF. I try searching online, but I haven't had much luck on how to do this from terminal.

因此​​,也许有人能告诉我如何创建一个罐子从终端表现。我知道命令:罐子CVF MyGreat.jar MyGreat

So maybe someone can tell me how to create a jar with manifest from terminal. I know the command: jar cvf MyGreat.jar MyGreat

但我如何才能在清单?在哪里我把清单与关于的.class 文件,以便在最后,我得到一个目录的jar文件: COM META-INF

But how do I get the manifest in? where to I put the manifest with respect to the .class files so that in the end, I get a jar file with directories: com and META-INF

推荐答案

您缺少冒号后<大骨节病>空格。这应该工作:

You are missing a space after the colon. This should work:

Manifest-Version: 1.0
Created-By: 1.7.0_51
Permissions: sandbox
Application-Name: MyFarmingBusiness
Application-Library-Allowable-Codebase: http://mycompany.com/version_4/myapplet/
Caller-Allowable-Codebase: www.mycompany.com
Codebase: www.mycompany.com

请注意额外的<大骨节病>空格应用程序库,Allowable- codeBase的经过:来电显示Allowable- codeBase的:项。

根据<一href=\"http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#Name-Value_pairs_and_Sections\"相对=nofollow> JAR文件规范,的定义是:

值:SPACE * otherchar新行*延续

value: SPACE *otherchar newline *continuation

如果您添加的空间,它按预期工作。

If you add the spaces, it works as expected.

这篇关于我如何注入新的清单成小应用程序的现有罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆