Using C# dll in java [duplicate]

2019-06-02 15:28发布

问题:

This question already has an answer here:

  • Calling C# dll from Java 2 answers

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 .

回答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.



回答2:

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.



标签: c# java dll