2014-09-11 108 views
0

我試圖在運行在resin中的本地主機上運行Java小程序。我有一個包含如下的JSP文件applet2.jsp:無法在本地主機上運行Java小程序

Testing an applet. 

<IMG SRC="/static/images/tabTrackerRollM.gif"><BR> 

<APPLET NAME="tracker" CODE="com.my.package" ARCHIVE="/applets/my_applet.jar" WIDTH="100%" HEIGHT="300" VIEWASTEXT MAYSCRIPT> 
<param name=updateUrl value="http://localhost/test/appletSample3.jsp"> 
<param name=bgColor value="0,0,0"> 
<param name=updateFrequency value=4000> 
</APPLET> 

但是,每當我試圖運行在瀏覽器中applet的我總是得到以下錯誤信息:

enter image description here

當檢查Java控制檯,我發現:

cache: Initialize resource manager: [email protected] 
basic: Added progress listener: [email protected] 
security: Expected Main URL: http://localhost/applet/my_applet.jar.jar 
basic: Plugin2ClassLoader.addURL parent called for http://localhost/applet/my_applet.jar 
network: Cache entry not found [url: http://localhost/applet/my_applet.jar, version: null] 
network: Connecting http://localhost/applet/my_applet.jar with proxy=DIRECT 
network: Connecting http://localhost:80/ with proxy=DIRECT 
java.io.FileNotFoundException: http://localhost/applet/my_applet.jar 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) 
    at sun.plugin.PluginURLJarFileCallBack.downloadJAR(Unknown Source) 
    at sun.plugin.PluginURLJarFileCallBack.access$000(Unknown Source) 
    at sun.plugin.PluginURLJarFileCallBack$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source) 
    at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source) 
    at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source) 
    at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source) 
    at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source) 
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source) 
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFileInternal(Unknown Source) 
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source) 
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.getJarFile(Unknown Source) 
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.access$1000(Unknown Source) 
    at com.sun.deploy.security.DeployURLClassPath$JarLoader$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.ensureOpen(Unknown Source) 
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.<init>(Unknown Source) 
    at com.sun.deploy.security.DeployURLClassPath$3.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source) 
    at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source) 
    at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source) 
    at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source) 
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) 
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) 
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) 
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) 
    at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source) 
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 

它基本上說my_applet.jar丟失。但是,當我試圖通過指向http://localhost/applet/my_applet.jar與我的瀏覽器訪問它,它實際上存在:

enter image description here

我也試圖去Java.com檢查,如果我有最新的Java: enter image description here

我下面的平臺上: OS:的Windows 7(64) 的Java: JDK 1.7(64)

我還清除了控制面板中的java小程序緩存,將瀏覽器安全設置爲中等並清除瀏覽器緩存。

回答

1

我們必須在瀏覽器上運行之前對applet進行簽名,然後才嘗試對applet Jar進行簽名。 這裏是簽名命令。

您應該在命令提示符下的同一個目錄中。

1.keytool -genkey -keyalg rsa -alias m4key //m4key unique key 
2.keytool -export -alias m4key -file bmcert.crt //bmcert.crt certificate name 
3.jar tvf Jarname.jar verify jar 
4.jarsigner Jarname.jar m4key 
5.jarsigner -verify -verbose -certs JarnameJarname.jar 
+0

嗨,喬治!是的,我忘記提及它已經簽署。 – epsac 2014-09-12 12:14:59

相關問題