Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running 32-bit dll on 64-bit machine in java

I am attempting to use a 3rd-party dll for a program I am writing in java. Unfortunately, it only has 32-bit support. When I attempt to load the dll in a 64-bit VM, I get the following error:

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

I have tried running in a 32-bit VM, which works in eclipse, but when I export the project, I get the same error. Please help!

Sincerely, Ben

like image 287
Ben Evans Avatar asked Nov 19 '12 06:11

Ben Evans


People also ask

Can 64-bit Java load 32-bit DLL?

On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL.

Can I run 32-bit and 64-bit Java on the same computer?

Yes, you can have both x64 bit and x32 bit Java installed. They won't create conflicts with with each other, as they're tied to the type of browser you're using.

Can I run 32-bit Java on 64-bit Windows?

However you cannot run 64bits program if your OS and IE belong to a 32bit architecture. Also you will not be able to install programs belonging to both bits on the same laptop. This will make the 32bit Java run but will not work for 64. Was this reply helpful?


2 Answers

You cannot use a 32-bit DLL in a 64-bit Hotspot JVM. It won't work. And I don't know of any other 64-bit JVM that supports 32-bit DLLs.

Indeed, as Peter Lawrey points out, this is not just a JVM limitation. No mainstream operating system allows an application running in 64-bit mode to load and use a 32-bit library.

Your choices are:

  • Switch to a 32-bit JVM. (You can run a 32bit JVM on a 64-bit OS ...)
  • Port the DLL to 64-bit.
  • Switch to an alternative library that is pure Java, or has a 64-bit DLL.

I have tried running in a 32-bit VM, which works in eclipse, but when I export the project, I get the same error.

That can only mean that you are running a 32-bit JVM to run the application within Eclipse, and a 64-bit JVM to run the application outside of Eclipse. (The issue is how you run the application, not how you export it ...)

like image 73
Stephen C Avatar answered Sep 18 '22 02:09

Stephen C


The only way to use a 32-bit shared library from a 64-bit JVM is to run an additional 32-bit JVM and access it via RMI, JMS or some form of messaging.

Its an intrinsic limitation of 64-bit programs (not just Java) that it cannot exchange pointers with a 32-bit library.

like image 21
Peter Lawrey Avatar answered Sep 20 '22 02:09

Peter Lawrey