Should native DLL and JRE address models match? - java

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.

Related

On installing Java for both 32bit and 64bit

How do you think set the PATH in Windows 7 64bit to have access to both 32 and 64 bit compilers. I have noteiced that appart from different folders everything such as java.exe, javac.exe, etc. are exactly the same. I believe the first path in the PATH variable (either with 32bit binaries or the 64bit) will take precedence.
My idea would be to change 64bit compiler's name (java.exe) and class execute program's name (javac.exe) and le't say add 64bit postfix but I am not sure if that would work. Please advice.
Thanks in advance.
java is not the compiler, that's javac. Also, the compiler generates the same byte-code on 64-bit as it does on 32-bit. Assuming you are using pure Java, the only distinction is in the run-time (or JRE) where a 64-bit JRE can address more memory. If you have native code then you must match the settings those libraries were compiled with . But, in general, if you are on a 64-bit system with more then 4 gigabytes of memory, only a 64-bit JRE can use the extra memory.

j2pkcs11.dll 64-bit version

Here is my problem:
I want to use j2pkcs11.dll in my java application. I downloaded dll from here and move it to system32 directory. When I run my code I have got :
java.lang.UnsatisfiedLinkError: C:\Windows\System32\j2pkcs11.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
My OS is windows 7 64-bit and my jre is 64-bit too. Obviously I need to get 64-bit version of j2pkcs11.dll but when I searched the web I could not find it anywhere. Any clue?
Ok, for those who may encounter this problem, it seems that there is no support for j2pkcs11 in jre-64bit. So I install 32-bit jre and select this jre as my runtime jre in Intellij.

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
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.

Is it OK to use 32 Bit eclipse RCP on 64 bit Mac OS X?

I got eclipse RCP juno 64 bit crashes on Mac OS X, and I posted this question in StackExchange Mac - https://apple.stackexchange.com/questions/67104/eclipse-rcp-juno-64-bit-crashes-on-mac-os-x. And, I guess I have no choice but to use 32 bit version now.
Is it just OK to use 32 bit eclipse on 64 bit OS (Lion), and 64 bit java (java 1.7 sdk)?
How about the code compatibility? Can I open the workspace with 64 bit eclipse created from 32 bit eclipse?
What's the difference between 32bit and 64bit eclipse? Or, what are cons and pros between them? Why do they keep 32bit eclipse in 64 bit world?
You need to 32-bit JVM to use 32-bit Eclipse, and you need 64-bit JVM to use 64-bit Eclipse.
Note that a 32-bit JVM can run on 64-bit OS. I have Windows 7 64-bit with both 32-bit and 64-bit JVMs installed. I do have to sometimes edit eclipse.ini file to make sure that the correct JVM is selected.
There are no workspace compatibility differences between 32-bit/64-bit variants of the same version. The native bits that are 32-bit/64-bit specific are for native UI and file system integration.
If you are running 64-bit OS, you should favor using 64-bit JVM/Eclipse. Doing so will avoid a lot of memory issues that plague 32-bit installs. For instance, it isn't uncommon for a 32-bit JVM/Eclipse to fail to start with -Xmx1024m due to address space fragmentation.
The 32-bit Eclipse builds are still produced because there are still quite a few 32-bit OS installs out there.

64-bit Eclipse and JVM

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.

Categories

Resources