Skip to content
Advertisement

Need to reference and use a C# dll in Java

I need to reference a .Net dll in java. I have used jni4net libraries for the same. I have followed the steps mentioned in the video below :

https://www.youtube.com/watch?time_continue=351&v=8OoSK_RWUe4

I have followed all the steps required to reference jni4net libraries but i get the following runtime Exception:

JavaScript

After following all the steps, This is my code:

JavaScript

I have tried executing the same using NetBeans 8.1 IDE but with no success. I am using jni4net-0.8.8.0 version and Eclipse IDE for Java Developers Version: Oxygen.3 Release (4.7.3) Any assistance would be helpful!

Advertisement

Answer

I used jni4net library to call c# dlls from java and it is working fine. I used a lightly different approach to initialize jni4net.

JavaScript

I needed to use full path c:… to the dll to make it work. I also had to take care about .net framework version used to create assembly (need to use 4.0 in my case and java version 8)

Hopes this helps

Advertisement