views:

41

answers:

3

I have made a Java Applet that depends on some third party libriaries as well as a DLL that is called via JNI. These will obviously not be installed on clients computers. Is there anyway to package these third party libriaries and external DLLs within my Applet's JAR so that it can be run by any client with a base Java install?

+1  A: 

Using JNI within a web application is a recipe for heartburn, particularly in Windows.

  • You obviously can't deploy the DLL within your WAR file and will probably require a separate installer be run by the deployer beforehand.
  • You'll have to ensure that your java.library.path is setup correctly, which is usually done by settings in the application server rather than something deployable in the WAR file.
  • The way that JNI links the native class with the library will cause class loader headaches if you try to run more than one instance of that web application. One way to work around this is to move the containing JAR file into a shared class loader (like Tomcat's common folder) but that has its own complications.
Alan Krueger
Thanks, figured it wouldn't be worth the headache. Off to find a different solution.
Petey B
+1  A: 

Is there anyway to package these third party libriaries

In Eclipse, under the Java project properties (right click), I can do a:

 Export... => Export as Runnable JAR

Then I tell it to pack my jar dependencies into that exported JAR. The exported JAR will have all its dependencies packed into it.

alt text

Bakkal
This won't handle native libraries required to support JNI native classes.
Alan Krueger
Never said so and not worth the headache. I truncated the OP's quote just to reflect that.
Bakkal
+1  A: 

I am no expert on the topic, but there are working solutions to all these problems. They might give you a headache, but some things can only be done this ways (and I am quite sure that your problem with the Entrust CSP is one of those).

You can take a look at OpenSign from the OpenOCES-project. The magic happens in org.openoces.opensign.client.applet.bootstrap.

I also believe that JNLPAppletLauncher solves the same problem, but I have no experience with i.

Rasmus Faber