Confused with 64bit and 32 bit when using JNI - java

I have a Java project running under windows. It uses several native functions from a .DLL file via JNI. Everything works well under 32bit windows.
In order to support 64bit windows, I need to deal with the following questions first:
Can I load a 32bit DLL under 32bit VM in 64bit windows?
Can I load a 32bit DLL under 64bit VM in 64bit windows?
Can I load a 64bit DLL under 32bit VM in 64bit windows?
How can I know which DLL file to load?
Thank you very much!

A 64-bit OS can run a 32-bit or 64-bit application.
A 32-bit application can only load 32-bit DLL or shared libraries.
A 64-bit application can only load 64-bit DLL or shared libraries.

Related

Unable to run .exe created in NetBeans(on 64-bit Windows 10) on 32-bit OS

I have created .exe file using Native Packaging, using Inno (http://www.jrsoftware.org/isdl.php).
NetBeans is installed on Windows 64-bit.
The .exe file runs on machine with same OS(64-bit), but when deployed doesn't run on 32-bit OS.
For the above issue, I copied the program from 64-bit Windows to 32-bit Windows and generated EXE using Netbeans on 32-bit Windows and then installed it on 32-bit system.

Eclipse is not opening on WIN10 64bit

I have Win 10 64 bit.
This is the log file in metadata folder:
Cannot load 64-bit SWT libraries on 32-bit JVM
Thanks I've installed 32-bit version and it worked!

Java native library architecture depend on JVM or OS?

I want to load native library to Java program, which is fine but I don't know which architecture should I load. If I'm running on x64 and I have a x64 JVM I will load 64 bit library but If I will run on x86 JVM on x64 what I should load ? It should be based on OS or JVM ?
Thank you
The "bitness" of the native library must be the same as that of the JVM.
If you are using a 32-bit JVM, you need a 32-bit native library (no matter if the OS is 32-bit or 64-bit).
If you are using a 64-bit JVM, you need a 64-bit native library.

JOGL 32 vs. 64 bit libraries error

I am new to JOGL. I use Eclipse and I imported JOGL jar and dll (yes, Windows OS). But, when I was searching for JOGL libraries, I downloaded 32 bit version. I have 64 bit OS, but since I can run 32 bit apps I thought it will still be more suitable. But compiler is complaining: Can't load IA 32-bit .dll on a AMD 64-bit platform
Well, first, I thought Java itself is NOT separated by architecture. Yes, I know I am using native libraries to link into Windows OpenGL interface (API), but I just want to include these code snippets into java bytecode, so why compiler cant let me use 32 bit ones? Thanks.
Since you have a 64-bit OS, you installed the 64-bit JVM. The 64-bit JVM cannot use the 32-bit DLLs, so you'll need to either download the 64-bit ones, or alternatively, install the 32-bit JVM on your system and set Eclipse to use that JVM instead.
64bit JVM cannot load 32bit libraries. You need to start 32b JVM to make it work (or get 64b dlls).

Java loading library windows 7 64bit

I have a java webstart program, it runs on xp, osx, vista, and windows 7.
I just tried to run it on windows 7 64bit and it is having a problem loading a library.
On this win7x64 machine I have the 64bit jdk/jre and the library it is not loading is swt-win32.dll. Yeah it's 32bit, but I'm getting:
Exception in thread "Thread-10" java.lang.UnsatisfiedLinkError: no swt-win32-3325 or swt-win32 in swt.library.path, java.libary.path or the jar file...
I have tried putting the dll on the java.library.path (physically copying it to the folder) and still get the exact same error. So am I getting this error because it's a 32bit dll or because it actually just can't find it? can the 64bit jdk/jre load/use 32bit dll's or do I need to either find the 64bit version of the dll or run the 32bit jdk/jre?
You have the answer already. 64-bit DLL's require the 64-bit JDK and 32-bit DLL's require the 32-bit JDK.
swt-win32.dll is actually a SWT UI framework(eclipse) dll. Try putting it in a directory which is in your system path.
If that doesn't work, then your next best bet would be to get the SWT binaries for 64 bit windows here. I think it works for windows Vista 64. There is no mention of windows 7 but it "should" work.

Categories