简体   繁体   English

适用于Java(JNI)的x86到x64库包装器

[英]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). 我有一个用于发送器设备的x86 dll(可能是用C ++编写的,但是当然没有任何来源)。 My OS is Windows 7 x64. 我的操作系统是Windows 7 x64。 I have JVM x64 too. 我也有JVM x64。 Is it possible to do smth with this x86 dll to use it with x64 JVM for native function call? 是否可以对此x86 dll做smth以便与x64 JVM一起使用以进行本机函数调用? The device manufacturer doesn't want write x64 version. 设备制造商不想编写x64版本。 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? 是否可以用C ++写一个x64 dll包装器,该包装器可以从dll中的API调用某些必需的函数并将其提供给外部?

Something like: 就像是:

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

You're going to have to use the 32-bit native code from within a 32-bit JVM. 您将必须在32位JVM中使用32位本机代码。 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. 要么编写外部32位程序以提供dll的接口,然后从JVM启动程序并与其通信。 For example, could do this through stdout/stdin. 例如,可以通过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. 这类似于Erlang驱动程序,这种方法的优点是可以使系统更加稳定。 eg if the driver program crashes you can just restart it from the JVM, it won't take down the JVM. 例如,如果驱动程序崩溃,则可以从JVM重新启动它,而不会关闭JVM。

Some advice for communicating with sub-processes is here: Running bash from Java 与子流程通信的一些建议在这里: 从Java运行bash

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM