static
static

Reputation: 8386

x86 to x64 library wrapper for java (JNI)

I have an x86 dll for an transmitter device (possibly written in C++, but there are no sources of course). My OS is Windows 7 x64. I have JVM x64 too. Is it possible to do smth with this x86 dll to use it with x64 JVM for native function call? The device manufacturer doesn't want write x64 version. Is it possible to write a x64 dll wrapper in C++, that could call some required functions from the API in the dll and provide them to outside?

Something like:

Java Native Function Call -> MyX64DLLWrapper.dll -> OriginalX86Lib

Upvotes: 4

Views: 1270

Answers (1)

BillRobertson42
BillRobertson42

Reputation: 12883

You're going to have to use the 32-bit native code from within a 32-bit JVM. Either that or write an external 32-bit program to provide an interface to the dll, and the launch the program from the JVM and communicate with it. For example, could do this through stdout/stdin. This is similar to an Erlang driver program, and an advantage to this approach is that it can make for a much more stable system. e.g. if the driver program crashes you can just restart it from the JVM, it won't take down the JVM.

Some advice for communicating with sub-processes is here: Running bash from Java

Upvotes: 2

Related Questions