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
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 ...)
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.
Related
Today when i migrate a project from old server to new server, i encounter this problem when i test the deployed service codes.
javax.servlet.ServletException: java.lang.UnsatisfiedLinkError: E802: Can't load shared library. E:\Rochade\bin\msvcr71.dll E:\Rochade\bin\msvcr71.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
no msvcr71 in java.library.path
i googled it on the internet and found some tips on installing a 36 bit jdk, i tried but didn't sovle the problem, does any one has any comment on this? i am really in hurry to get this problem solved, which is the road block for us moving forward on the migration process.
I think you cannot load library compiled for 32-bit architecture in 64-bit environment.
Solution is to recompile the library for x64 or obtain 64-bit version if you do not have its sources.
You either can use a 32-bit JVM or install the 64-bit version of the Microsoft Visual Studio C/C++ Redistributable Package.
Or better reinstall the software on the new server. Moving only the folders to a new computer is not a good idea on Windows, especially when the old PC was a 32-bit system and the new PC is a 64-bit system.
Can 32 bit native DLL be loaded from 64 bit JRE? If not what is the best solution?
Should user install both 32 and 64 bit versions of JRE?
Thank you.
Both 32-bit and 64-bit versions of the JRE would need to installed and used accordingly. Note, this is not requirement of the JRE but of Windows. From Programming Guide for 64-bit Windows:
... 32-bit processes cannot load 64-bit DLLs for execution, and 64-bit processes cannot load 32-bit DLLs for execution.
If you want to use a 64-bit JVM but have a 32-bit DLL you need to use, you can run both and have the 64-bit JVM talk to the 32-bit JVM when it needs to the DLL to do something.
I'm using skype-java-api to use skype in Java. The only feature that i need is to dial phone numbers on click. It works fine on windows XP x86, but i just tested it on a Windows 7 x64, and it fails. The error is:
Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: C:\Users\Vazdautan\AppData\Local\Temp\skype.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
Are there any other cross-platform alternatives(for MAC and Windows) or is it possible to solve it somehow ?
Thanks, Andrew.
You can run a 32-bit JVM on a 64-bit OS.
If you want to run a 64-bit JVM, you can use this to run a 32-bit JVM either as a service or on an ad-hoc basis.e.g. With Runtime.exec()
Or Skype provide a 64-bit DLL in which case I would just use that.
How do I tell if I am using 64-bit Eclipse and 64-bit JVM on my Linux machine?
To verify that you are using 64-bit JVM:
java -d64 -version
In a comment above you say that you're using a software package that requires "such constraints". I'm not exactly sure what you mean by that, but for Java programs, it doesn't matter if the underlying Java implementation is 32-bit or 64-bit (well, as long as it doesn't need a huge amount of memory, for example). A normal Java program should run the same, no matter if it runs on a 32-bit or 64-bit OS.
java -version should give you an indication if your Java runtime environment is 32-bit or 64-bit.
Eclipse contains some native binaries (for the SWT libraries). Depending on if your Java runtime environment is 32-bit or 64-bit, you need a version of Eclipse with the corresponding native binaries. The Eclipse download page contains links for 32-bit and 64-bit Linux versions of Eclipse.
Note: If your OS is 64-bit but your Java RE is 32-bit, you will still need the 32-bit Eclipse.
Usually you can tell from your eclipse.sh or your eclipse.ini if you are using 32bit or 64bit version, as the involved plugins are quite different.
As for the JVM, are you running Eclipse with something other than your default JVM? 'which java' usually tells you what you're using as your java executable.
I'm running 64-bit version of Vista on my notebook with 4G of RAM, the Ram is maxed out at 1.5G on the 32-bit version of Java. But if I move completely to 64-bit version of Java, the JDIC part won't work, so my question is : if I install both 32 and 64 bit versions of Java, can Netbeans easily switch between the two ? So if I run out of ram at 1.5G, I switch to the 64-bit, but if I need to develop JDIC part, I switch back to the 32-bit, is this possible with Netbeans ?
========================================================================
I've just realized I asked half a question, since which version(32/64 bit) of Netbeans also matters. So my question should be : If I run 64-bit of Neatbeans(assume it's available), and have both versions of Java installed, can I switch between the two Java versions for my projects in Netbeans ?
NetBeans does work with both 64-bit and 32-bit JVM. Eclipse can only work with 32-bit JVM. I have a script for launching Eclipse with installed 32-bit JVM and NetBeans for the 64-bit or 32-bit JVM.
You cannot switch JVMs in a running app. You'll have to restart it, but you should certainly be able to run Netbeans in both JVMs.