2013-01-13 49 views
3

我已經做了一個Java Swing GUI,並試圖把它放到一個網站上,我把我的HTML文件放在lwjgl_jar文件夾中,並解決my previous problem關於無法找到AppletLoader,但我現在得到一個新的錯誤:簽署我的Jar文件

Permissions for Applet Refused. Please accept the permissions dialogue to allow the applet to continue the loading process. 

告訴Java「運行這個時間」後出現錯誤。所以我在網上搜索,發現我的問題的解決方案是我的jar文件沒有被簽名,這是奇怪的,因爲我使用Slick和lwjgl文件,我認爲它應該已經簽名,但是我的racegame.jar持有我的小應用程序可能需要簽約,所以我也跟着this guide to signing jars

,併到了最後一步,鍵入:jarsigner -keystore myKeystore racegame.jar myself 讓我簽字racegame.jar但它說:

jarsigner: unable to open jar file: racegame.jar 

也會出現此錯誤與任何其他jar我嘗試使用它。

爲什麼不打開jar文件並簽名?所有其他步驟都按照他們在指南中所顯示的那樣進行了跟蹤和測試。

+0

http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/jarsigner.html與此相比較。 – vels4j

+0

請看看這個[文檔](http://gagandeepbali.uk.to/gaganisonline/swing/downloads/signJARfiles.txt),可能它有些東西可以幫助你。雖然鏈接只有在我的電腦正在運行時纔會激活(ON STATE)。 –

+0

謝謝Gagandeep,你的回答幫助我解決了我的問題,請回答我的問題,以便我可以選擇你的答案。 –

回答

1

我曾經在網上發現過有關How to sign the JAR Files的這篇文章,這可能會有一些內容,它可以幫助你。請看看:

Sign All Applet JAR files 

Applets are back! And now applets can do more than ever before thanks to 
signed JAR files. By signing your JARs, you can get access to the filesystem 
and other resources that were previously off-limits, provided the user 
grants your applet those privileges. And signing JAR files is now very easy 
thanks to tools bundled with the JDK. However, be certain to sign all JAR files 
used by your Java applet. If you sign the JAR file with your main applet class, 
your applet will launch. If it later uses classes from another JAR file, though, 
you can run into trouble. If the newly-loaded class tries a restricted operation 
and its JAR file isn't signed, your applet will fail at that point with a 
security exception. Rather than waiting for this and debugging it when it occurs, 
save yourself the trouble and sign all of your JAR files up front. 

You can create your own certificate using tools provided by the JDK. 
keytool -genkey -alias mykey lets you create your own certificate. Be sure to 
specify an expiration date far in the future with -validity 1000. The default is 
only 6 months. 

Sign your JAR files with jarsigner my.jar mykey (where my.jar is the name of 
the jar file to sign). 

Deploy all of your JAR files to a folder on your web server, add an HTML page 
with the applet tag, and let the world enjoy your new applet with powerful 
permissions. 

keytool -genkey -v -key store mycompany.keystore -alias myalias_goes_here -keyalg RSA -keysize 2048 -validity 10000