epsac
epsac

Reputation: 198

Unable to run Java applet in localhost

I'm trying to run a Java applet in my localhost running in resin. I have a JSP file applet2.jsp which contains the following lines:

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>

However, whenever I try to run the applet in my browser I'm always getting the following error message:

enter image description here

Upon checking the Java Console, I found the following:

cache: Initialize resource manager: com.sun.deploy.cache.ResourceProviderImpl@9da1dd
basic: Added progress listener: sun.plugin.util.ProgressMonitorAdapter@1a0d62f
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)

It basically say that my_applet.jar is missing. But when I try accessing it with my browser by pointing to http://localhost/applet/my_applet.jar, it actually exist:

enter image description here

I also tried going to Java.com to check if I have the latest Java: enter image description here

I'm on the following platform: OS: Windows 7 (64) Java: JDK 1.7 (64)

I also cleared the java applet cache in the control panel, setting the browser security to medium and clearing my browser cache.

Upvotes: 0

Views: 1126

Answers (1)

George Rosario
George Rosario

Reputation: 781

We have to sign the applet before running it on the browser did you try signing your applet Jar. here is the signing commands.

You should be in the same directory in command prompt.

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

Upvotes: 1

Related Questions