Dynamically load additional jar files using Web Start / JNLP

可紊 提交于 2019-12-06 01:52:18

问题


The Web Start Developers Guide states

All application resources must be retrieved from the JAR files specified in the resources section of the JNLP file, or retrieved explicitly using an HTTP request to the Web server.

Storing resources in JAR files is recommended, since they will be cached on the local machine by Java Web Start.

Now, I have some resources I want to dynamically load after my application has been started (for example OSGi bundles). I can do this using plain HTTP, but I would like to make use of Web Start's support for local caching and versioned/architecture-specific resources.

Is there a way to download additional jar files from the original code base (as specified in the application's jnlp file) using the Web Start infrastructure?

Or alternatively: is there already an established way to integrate OSGi and Web Start that would relieve me of the task to install bundles from the Web Start server?


回答1:


If you make your application in itself an Equinox-based OSGI application, you can web-start it with all the addition bundles you need.

This article "WebStarting Equinox OSGi Apps" can give you a good introduction on the required settings.

  • All bundles have to be deployed as signed JAR files
  • You need a feature that contains all the necessary bundles
  • When exporting the feature, make sure that PDE creates a JNLP (Java Network Lauching Protocol) file (a checkbox in the export wizard) for this feature
  • Provide a root JNLP file for you application
  • Deploy your application to a web server and make sure that the web server is aware of the application/x-java-jnlp-file mime type

He also has an OSGI demo.




回答2:


I haven't tried it but look at the javax.jnlp.DownloadService API



来源:https://stackoverflow.com/questions/657157/dynamically-load-additional-jar-files-using-web-start-jnlp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!