6

I am having trouble with getting and applet to work on an HTML page. When I remove the socket connection from the applet class and test the applet on an HTML page the applet displays but when I add the socket connection back in the class file the applet doesn't display and the Java console appears with no stack trace. I'm sure this is a security reason because I'm using socket connections so what I did was create a signed jar file and placed that in the applet tag as so:

<APPLET codebase="classes" archive="captureaudio/AppletTest.jar" code="captureaudio/AppletTest.class" width=350 height=200></APPLET>

But creating this signature has not worked.

Can somebody help me with this?

UPDATED

In response to Andrew Thompson

  1. No im not prompted to accept digital signed code
  2. No the applet im currently testing is locally
  3. Yes the applet is trying to connect back to the server, ther server is running locally
  4. Im not sure the java console isnt showing me any exceptions.

HOW I CREATED THE SIGNED JAR FILE

The namespace of my Applet is captureaudio.AppletTest class

At cmd prompt, where teh class file is located:

  1. You need to use the keytool.exe here is where i found how to create a jar signature for applets www.xinotes.org/notes/note/434/

  2. jar -cf AppletTest.jar AppletTest.class

  3. >jarsigner AppletTest.jar MyCert Warning: This jar contains entries whose signer certificate will expire within six months

4.>jarsigner -verify -verbose -certs AppletTest.jar

s k 153 Thu Oct 13 11:28:38 BST 2011 META-INF/MANIFEST.MF

  X.509, CN=xxxxx, OU=None, O=None, L=xxxxx, ST=xxxxx, C=GB (myce

rt) [certificate will expire on 10/01/12 20:55]

     315 Thu Oct 13 11:28:40 BST 2011 META-INF/MYCERT.SF
    1352 Thu Oct 13 11:28:40 BST 2011 META-INF/MYCERT.RSA
       0 Thu Oct 13 11:28:10 BST 2011 META-INF/

smk 11015 Thu Oct 13 10:49:08 BST 2011 AppletTest.class

  X.509, CN=xxxxxx, OU=None, O=None, L=xxxxxxxx, ST=xxxxx, C=GB (myce

rt) [certificate will expire on 10/01/12 20:55]

s = signature was verified m = entry is listed in manifest k = at least one certificate was found in keystore i = at least one certificate was found in identity scope

jar verified.

JAVA CONSOLE

Java Plug-in 10.0.0.147 Using JRE version 1.7.0-b147 Java HotSpot(TM) Client VM

User home directory = C:\Users\xxxxxxx

c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache

0-5: set trace level to

Detected from bootclasspath: C:\PROGRA~1\Java\jre7\lib\deploy.jar

UPDATE

Folder locations

 web root> 
------AppletTest.jar
------classes>
-----------captureaudio>
---------------------AppletTest.class    
redoc01
  • 2,107
  • 5
  • 32
  • 64
  • 1) Are you being prompted to accept the digitally signed code? 2) Is the applet available for us to visit? 3) Is the applet attempting to connect back to the server, or somewhere else? 4) Is the code swallowing exceptions? – Andrew Thompson Oct 13 '11 at 10:59
  • 1) If you are not being prompted to accept the code, the JRE does not consider it to be signed. 2) Pity, that sometimes helps with debugging. 3) The applet should not need extended permissions to 'phone home'. If you ever need permissions in that case, it is likely that the applet is forming the address incorrectly. 4) That does not specifically answer my question. 5) Good call on addressing each question explicitly. – Andrew Thompson Oct 13 '11 at 11:14
  • @AndrewThompson, Hi i have updated the details again, this is to do with signing the applet hope this could help, could give it a last try, i could be signing the applet incorrectly. – redoc01 Oct 13 '11 at 11:30
  • Your JarSigner -verify output seems to suggest it is signed OK. It is very odd you are not being prompted. Can you try it on a different machine and report the behavior? Are those Xs in the output are edited for privacy? – Andrew Thompson Oct 13 '11 at 12:53
  • @AndrewThompson yes, the x's are for privacy, the details in their are my own. Thanks again Andrew ill do as what you have instructed. – redoc01 Oct 13 '11 at 13:26
  • Have you tried include a **java.policy.applet** inside the default package, also are your socket trying to connect to the same address as the HTTP server? – Alexandre Lavoie Apr 29 '13 at 16:20

1 Answers1

0

Use the Java Network Launching Protocol (JNLP). That is the right way to distribute you applet. And yes, it must be signed, to access the socket functionality.

http://en.wikipedia.org/wiki/Java_Web_Start#Java_Network_Launching_Protocol_.28JNLP.29 http://www.oracle.com/technetwork/articles/javase/jnlp-142088.html

Daniel De León
  • 13,196
  • 5
  • 87
  • 72