简体   繁体   English

部署具有第三方依赖关系的Java Web Applet

[英]Deploy Java Web Applet with Third Party Dependencies

I have made a Java Applet that depends on some third party libriaries as well as a DLL that is called via JNI. 我制作了一个Java Applet,它依赖于某些第三方库以及通过JNI调用的DLL。 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? 无论如何,我的Applet JAR中是否打包了这些第三方库和外部DLL,以便任何安装了基本Java的客户端都可以运行它?

Using JNI within a web application is a recipe for heartburn, particularly in Windows. 在Web应用程序中使用JNI是导致胃灼热的秘诀,尤其是在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. 您显然无法在您的WAR文件中部署DLL,并且可能需要事先由部署程序运行单独的安装程序。
  • 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. 您必须确保正确设置了java.library.path ,这通常是通过应用程序服务器中的设置完成的,而不是通过WAR文件中可部署的设置完成的。
  • 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. 如果您尝试运行该Web应用程序的多个实例,则JNI将本机类与库链接的方式将引起类加载器的麻烦。 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. 解决此问题的一种方法是将包含的JAR文件移动到共享的类加载器(例如Tomcat的公共文件夹)中,但这有其自身的复杂性。

Is there anyway to package these third party libriaries 反正有打包这些第三方库的东西吗

In Eclipse, under the Java project properties (right click), I can do a: 在Eclipse中,在Java项目属性(右键单击)下,我可以执行以下操作:

 Export... => Export as Runnable JAR

Then I tell it to pack my jar dependencies into that exported JAR. 然后,我告诉它把我的jar依赖关系打包到导出的JAR中。 The exported JAR will have all its dependencies packed into it. 导出的JAR将打包所有依赖项。

alt text http://www.ubuntu-pics.de/bild/97131/selection_016_mg6IDm.png 替代文字http://www.ubuntu-pics.de/bild/97131/selection_016_mg6IDm.png

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). 它们可能使您头疼,但是有些事情只能通过这种方式来完成(我非常确定,Entrust CSP的问题就是其中之一)。

You can take a look at OpenSign from the OpenOCES-project . 您可以从OpenOCES-project看一下OpenSign The magic happens in org.openoces.opensign.client.applet.bootstrap. 魔术发生在org.openoces.opensign.client.applet.bootstrap中。

I also believe that JNLPAppletLauncher solves the same problem, but I have no experience with i. 我也相信JNLPAppletLauncher可以解决相同的问题,但是我对i没有任何经验。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM