Reputation: 643
We are developing a Java application to be run on Linux environments (Ubuntu for now) which communicates with a piece of hardware. Said hardware uses a .so library made available by the manufacturer for x86 architectures only.
The thing is, we would very much like to run this on a 64bit JVM. Loading the library in a x86 JVM works fine but we cannot load on the 64bit version. So, besides switching to a x86 JVM, are there any other ways to make this lib available to my 64 bit Java application? Is it possible, for instance, for me to write another os wrapper library in x64 that, in turn calls the x86 version so the JVM can load my 64 bit wrapper?
Upvotes: 3
Views: 2154
Reputation: 133
with this code you can check if you are on a 64bit pc and load the lybrary:
boolean is64bit = System.getProperty("sun.arch.data.model").contains("64");
if(is64bit){
try {
System.load("64Bit ibrary");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
}
else{
try {
System.load("32Bit ibrary");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
}
}
Upvotes: 1
Reputation: 1
No.
You can not load a 32-bit library into the address space of a 64-bit process.
Upvotes: 9