• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

sharing classes among signed applets

I have quite a number of signed applets, and all applets need to use some common classes, is there any good way to share the classes?

Currently the common classes are put in some JAVA packages, although recompilation is not needed, they have to be included in each applet (another inconvenience is that I have to duplicate the common class files for each applet during signing) which is quite troublesome, especially when some code is to be changed in the common class.

Any good solution?  (must work for both IE/Netscape)
  • 4
  • 3
  • 3
1 Solution

a.jar - classes of 1st applet
b.jar - classes of 2nd applet common.jar - common clases
HTML for 1st applet
<applet arhcive="a.jar;common.jar">
HTML for 2nd
<applet arhcive="b.jar;common.jar">

make all methods public in common jar
The bearer of bad news...

I thought you had to use a cab file to get signed code in IE?

Also Netscape before 4.5 will only open the first jar file.

To get reliable signed code that is fairly backwardly compatible in both IE and NN I think you are going to need something like this:

<applet code="MyApplet.class" ARCHIVE="MyApplet.jar" width=600 height=350>
<param name="CABBASE" value="MyApplet.cab">

with separate signed cab and jar files. I would be interested to know if there is a way around this that works.

EG: from MSDN:

Question 5
Can I sign a Java class file for use with Internet Explorer?

A. Although it is possible to digitally sign a Java class file and verify the signature using the ChkTrust utility, Internet Explorer does not recognize the class as signed and present a certificate to the user at runtime, furthermore, the class is not considered trusted by the Microsoft VM. Presently, you need to place the classes within a CAB file, which can then be signed.

Question 6
Will the Microsoft virtual machine support the JAR file format?

JAR support is the same as ZIP. JAR = ZIP + manifest. It will support uncompressed and compressed JAR levels 0 and 1, but not signed JAR. If you need Java security (beyond sandbox), on Internet Explorer 4.0 you need to use a signed CAB file. This applies to all fine grained Java security (including running in a sandbox on the local computer using the package manager).

A definitive resource on signing is here, that may help you:


There is also a script here for creating and packaging both jar and cab files in one easy(er) step.

fasterAuthor Commented:
I am only interested in the sharing of class, not how to use signed applet.  Yes I use cab for IE and JAR for Netscape.

I need a way that works for both IE and Netscape, and I need to support Netscape 4.0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

If you need to support nescape 4.0 then you can only have one jar file.

So for NN you would need to combine the common.jar vladi21 suggests with the b.jar, for example, and make a single jar file. IE is fine with 1 or more jar files or cab files.

The classes live in a common package which is imported into and used in many applets, so I'm a bit unclear about what else you mean by sharing the classes other than to package them in with your applets as valdi21 suggests.
fasterAuthor Commented:
that is what i am doing now, but I want to avoid generating each jar file again when I change the common class
fasterAuthor Commented:
I tried Netscape 4.06 but it works fine for two .jar files.  what is the lowest version of netscape that supports this feature? Where I can get information on this?
Does Netscape support multiple JAR files per archive tag?
In 4.0.5, yes, this feature is supported.  In prior versions, it is not.  You will have to create one single JAR archive containing all of your files.

also look:
Use a JAR/ZIP/CAB file with an Applet

Code signing resources:
Creating Signed, Persistent Java Applets




NN: Bypass the need for a certificate
Netscape provides a way to accept a codebase as trusted (then a certificate is not needed). This can be useful during development or in a private Intranet. In the Netscape Users directory, there is a file called prefs.js. Adding the line user_pref("signed.applets.codebase_principal_support", true);

will enable JAR file without a certificate to request privileges on your machine. If you agree, it will be possible for an Applet to lauch a program, write a file on your hard disk or print on the printer. You will still have to ask for privileges in your program using the Netscape capabilites classes.
Another way is to lower general security setting to more allow more freedom when running applets locally. Add or modify the following entries in the prefs.js: user_pref("unsigned.applets.low_security_for_local_classes", true);
user_pref("signed.applets.local_classes_have_30_powers", true);
user_pref("signed.applets.low_security_for_local_classes", true);
user_pref("signed.applets.verbose_security_exception", true);

Then you don't need to asked for privileges for local classes.
When adding or modifying the file prefs.js, Netscape must not be running because your modification will be overwritten. So shut down Netscape, edit the prefs.js and then restart Netscape.
fasterAuthor Commented:
do you any restriction in Netscape JNI for versions prior to 4.06?  I have a JNI DLL which works for 4.06 and above but crash for lower versions.
FYI faster...

I've been looking for this stuff (http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=10215402
) regarding this q but couldn't find it, from one of my previous PAQ's.

This link here gives the info I originally found out about NN 4.5 not supporting multiple Jar files.

As luck would have it The Swing Connection site is only partially working at the moment, but when it is up again look here for a page of useful info on explorer and navigators handling of archive files:


Also, from the second page here:


To quote...

"Navigator will throw a java.lang.NoClassDefFoundError when a class file in A.jar references a class in B.jar. Navigator 4.05 and the JDK1.1 support patch for Navigator 4.04 supposedly fix this problem..."

So you may be able to fix older versions of NN if necessary anyway.


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 4
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now