开发者

How to make Jar which includes DLL?

I have a Jar which fetches the DLL from some path whi开发者_C百科ch is specified in configuration file. I keep that configuration file at the location from where I am executing my application. That DLL is also installed somewhere else.

Now I want to make my Jar which should consist of (classes &) DLL. I don't want to give any path because that configuration file may not be present.

How to proceed with this? How to make jar and what changes do I need to do?


If your app. has a GUI, the easy way to include native libraries on the run-time class-path of the application is to use Java Web Start to deploy it. Here are how the resource sections of the JNLP launch file might look.

<resources >
    <j2se version="1.6+"/> 
    <!-- Supply this resource to all -->
    <jar href="ourapp.jar" size="100000" />
</resource>
<!-- Supply this resource to SunOS/sparc only -->
<resources os="SunOS" arch="sparc">
    <nativelib href="sunlibs.jar" size="250000" />
</resource>
<!-- Supply this resource to Windows only -->
<resources os="Windows">
    <nativelib href="winlibs.jar" size="300000" />
</resource>

JWS partitions the downloads, so Mac. and any non SunOS *nix get just 100,000 bytes of core Java. SunOS gets a total download of 350,000 bytes, and Windows gets 400,000 bytes. The application can then load the native using something like:

System.loadLibrary("ournative");

After that, the native should be loaded and ready for use in any OS for which a native was supplied.

Deployment via. JWS has a number of advantages, including:

  • A cross-platform and convenient way to deploy natives.
  • Partitioned download of the natives.
  • Automatic update of application resources (classes, natives, etc..)
  • Avoiding "DLL Hell" by way of the automatic updates.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜