DLL and JNI

Hi everyone,

My problem is I need to call a C++ dll from Java. Some tools like JIntegra are perfect for this, except that my DLL isn't a COM component.

So I see 2 solutions, writing a COM wrapper for the dll (in C++, ouch), or using JNI (where I am a newbie).

But for the second, all examples I saw are about to build a shared dll for others applications. But for me it is exactly the opposite : I already got the dll, and I want to make method calls from this one into my Java code.

Does anyone knows how can I do that ?

Can I extract the JNI interface from the dll ?

Some open sources applications can help me ?

Many thanks

[676 byte] By [golgotia] at [2007-11-27 2:56:30]
# 1

Hi,

Java providers have no idea how could be solved problems with Native Code. JNI SDK is very complex in use (I am writing JNI code for six years and hate JNI). Java Language should include something simple that enables easy calls to native functions. Just now I am implementing DONET Platform Invoke paradigm in Java called Java Platform Invoke (J/Invoke). It is developed for JDK in MS Windows. The next version will be for Linux. See the last update of J/Invoke Demo at

http://www.sharewareplaza.com/Java-Platform-Invoke-API-Demo-version-download_49212.html

vitallisa at 2007-7-12 3:34:17 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
I am sure there is others ways to do it ...Has someone tried SWIG?
golgotia at 2007-7-12 3:34:17 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

To let you know ...SWIG is really a great tool, and make a lot of wrapping classes in Java. It works perfectly, even for making wrapping classes of C++ templates ( Smart Pointers and so on ...).

JNI is very hard to deal with, but SWIG can do it for you. I don't have shares in SWIG, but really try this one ..

golgotia at 2007-7-12 3:34:17 > top of Java-index,Java HotSpot Virtual Machine,Specifications...