Im trying to use external .dll file coding in c# ,in my Java application , what I know about the dll that it contains interfaces with functions we can use ,I can load the dll to my java application , but how i can use the interfaces within it ? I dont know how JNI can help in this case .Please help .
Asked
Active
Viewed 4,885 times
2 Answers
1
I suspect you'll need to use a Java/COM bridge such as JACOB, or Java Native Access (you'll likely have to write a bridge, since JNA is for native access only).
See this SO answer for more details.

Community
- 1
- 1

Brian Agnew
- 268,207
- 37
- 334
- 440
1
You can create native exports from your C# DLL using a project template written by Robert Giesecke. This allows you to create native C-style API exports in your C# DLL, and call them from Java or almost any other language. Scroll down to the bottom of the page for the Unmanaged Export Library file.
Alternatively, you could use ComVisible
to create a COM class and access it from Java.

Polynomial
- 27,674
- 12
- 80
- 107
-
should I put the class which is using ComVisible in dll file and then using it in java app?if so , how i should import it and call it? – ama Jul 25 '12 at 10:50
-
Yes. Here's [an example](http://msdn.microsoft.com/en-us/library/c3fd4a20.aspx). You'll need to mark the DLL as COM Visible too. Have a read through [this question](http://stackoverflow.com/questions/7092553/turn-a-simple-c-sharp-dll-into-a-com-interop-component) for some more info. Brian Agnew's answer covers using COM in Java. – Polynomial Jul 25 '12 at 10:53