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)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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="">

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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 (
) 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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.