Question

I created a JApplet which uses two external libraries (JENA and JUNG). The applet works correctly when i run it from the IDE (using eclipse). I created a jar file, signed it (since the applet needs to read text from disk), created an HTML page to hold the applet, however when i try to run it in a web browser i get the java security warning dialog and when i press run the whole browser tab seems to hang.

Here is the HTML file i wrote:

<html>
   <head>
      <title>Ontology Application</title>
   </head>
   <body>
      <applet code="assignment.Launcher.class" width="1000" height="800" archive="test.jar"></applet>
   </body>
</html>

The Launcher class contains the init, start, stop and destroy methods, and all the classes used in the project are stored in the assignment package. test.jar is the signed jar file and it is placed in the same folder as the HTML file.

I followed the steps in this thread to create my private/public key, certificate and to sign the jar file: How to sign and applet (and get it to work)

I have a list of questions about the whole process since i am unsure about a couple of steps.

Question 1: I created the jar file using eclipse (Right Click project -> export -> JAR file) and kept the default settings. Does the resultant jar file contain the references libraries i imported into the project? if the answer is no, how do i include referenced libraries in the jar file?

Question 2: Should the resultant jar file run if I double click it? since it doesn't run (I think it doesn't work because no main class is specified since an applet doesn't have a main method, but i stand to be corrected)

Question 3: Since I am using external libraries in my applet, do i need to digital sign all the imported jar files in order to make the applet work? or signing the main jar file (containing my classes) is enough?

Question 4: If someday i manage to make the applet work in a browser, will the java security warning dialog pop up every time the application tries to read text from disk? or the security warning dialog shows up only once when the applet is loading?

Thanks in advance, and sorry for asking loads of questions in one thread, however they are closely related to the subject :)

Was it helpful?

Solution

  1. You should use <PARAM NAME="archive" VALUE='applet.jar, external1.jar, external2.jar'> in your applet declaration in the HTML. You can also try adding Class-Path to your MANIFEST.MF of the main jar (see here)
  2. No. Unless you have a Main-Class specified in your MANIFEST.MF
  3. Yes, in case the external jars do some security-sensitive operations (like reading/writing the file system)
  4. No.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top