Using C# dll in java [duplicate]

2019-06-02 15:29发布

This question already has an answer here:

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 .

标签: c# java dll
2条回答
乱世女痞
2楼-- · 2019-06-02 15:57

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.

查看更多
Emotional °昔
3楼-- · 2019-06-02 16:20

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.

查看更多
登录 后发表回答