简体   繁体   English

如何为32位和64位计算机分发依赖于DLL的应用程序

[英]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). 我有一个使用第三方jar(utils.jar)的应用程序,它调用第三方DLL(utils.dll)。 The jar file manages calls to DLL including the name of the DLL. jar文件管理对DLL的调用,包括DLL的名称。 There is a 32-bit version and a 64-bit version of the DLL. 有一个32位版本和64位版本的DLL。

Currently, the application can only run on 32-bit machines. 目前,该应用程序只能在32位计算机上运行。 When I try to run it on a 64-bit machine, it tells me 当我尝试在64位机器上运行它时,它会告诉我

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. 当我用64位替换32位dll时,它工作正常。 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). 如果可以避免它,我不想维护两个单独的版本(一个使用32位库,另一个使用64位库)。 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. 我们的项目是使用Ant构建的,但我可以在必要时探索其他替代方案。

You have to create an additonal ant target such that it builds always a x32 and a x64 variant of your application. 您必须创建一个额外的ant目标,以便它始终构建应用程序的x32和x64变体。

I don't want to maintain two separate releases 我不想保留两个单独的版本

If the ant your skript always produce both deliverys that its not much addional effort. 如果蚂蚁你的skript总是产生两个交付,它没有多少额外的努力。

When you do loadLibary you could compose the library name with the System.getProperty("os.arch") . 当你执行loadLibary时,你可以使用System.getProperty("os.arch")组成库名。 So, you bundle all dlls, and the related version will be chosen at run-time. 因此,您捆绑所有dll,并在运行时选择相关版本。

For deploying Java desktop apps., the best option is usually to install the app. 对于部署Java桌面应用程序,最好的选择通常是安装应用程序。 using Java Web Start 1 . 使用Java Web Start 1 JWS works on Windows, OS X & *nix. JWS适用于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.. JWS提供了许多吸引人的功能,包括但不限于启动屏幕,桌面集成,文件关联,自动更新(包括延迟下载和程序控制更新), 按照平台,架构或Java版本对配置进行本机和其他资源下载 ,配置运行时环境(最小J2SE版本,运行时选项,RAM等),使用扩展轻松管理公共资源。

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

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