简体   繁体   中英

How to distribute an application that relies on DLL's for 32-bit and 64-bit machines

I have an application that uses a 3rd party jar (utils.jar), which calls a 3rd party DLL (utils.dll). The jar file manages calls to DLL including the name of the DLL. There is a 32-bit version and a 64-bit version of the DLL.

Currently, the application can only run on 32-bit machines. When I try to run it on a 64-bit machine, it tells me

Can't load IA 32-bit .dll on a AMD 64-bit platform

When I replace the 32-bit dll with the 64-bit, it works fine. I don't want to maintain two separate releases if I can avoid it (one using 32-bit library, the other using 64-bit library). Is there a way to build the application so that it can figure out which version of the library it needs to use?

Our projects are built using Ant, though I can explore other alternatives if necessary.

You have to create an additonal ant target such that it builds always a x32 and a x64 variant of your application.

I don't want to maintain two separate releases

If the ant your skript always produce both deliverys that its not much addional effort.

When you do loadLibary you could compose the library name with the System.getProperty("os.arch") . So, you bundle all dlls, and the related version will be chosen at run-time.

For deploying Java desktop apps., the best option is usually to install the app. using Java Web Start 1 . JWS works on Windows, OS X & *nix.

  1. JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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