Monday, July 23, 2018

Using C# DLL file in Java project with JNI4NET

Hi, it's me, Lumzuee Pharm!
Today I'm going to show you how to use C# dll file in Java project (I used Visual Studio & NetBean) with JNI4NET. Actually there are 2 common methods for this problem: JNI4NET & JAVONET. But Javonet is a paid solution & I don't like this :3

Requirement:
- Java JDK, .NET SDK,
- add csc.exe & javac.exe to the PATH
- Visual Studio
- Java IDE (netbean, eclipse,...)
- lib files: jni4net.j-0.8.8.0.jar, jni4net.j-0.8.8.0.dll, jni4net.n.w64.v40-0.8.8.0.dll, yourLib.dll
- build tool: proxygen.exe, proxygen.exe.config & cmd file to run proxygen.

Creating proxies:
- put necessary files to a folder "create lib"
- run "create proxies.cmd", it will run proxygen.exe
- run "build.cmd" in folder "output"
- copy 2files: "yourLib.j4n.dll" & "yourLib.j4n.jar" to folder "lib"
- copy lib files into folder "lib"