MMJ
MMJ

Reputation: 537

Can I add JAR file as library in C# project

Can I add .JAR file as a library in my C# project? If I can do that it will help me to save writing duplicate codes for JAVA & for C#.

I looked at "https://github.com/jni4net/jni4net/" but didn't get the answer if I can really called the API written in .JAR files.

Thanks in Advance!

Upvotes: 0

Views: 4799

Answers (1)

MMJ
MMJ

Reputation: 537

I was able to use JAR file in C# after converting it into DLL using ikvm. Here's the steps I followed:

  1. Download the latest version of iKVM from https://sourceforge.net/projects/ikvm/ & Unzip the zip file.
  2. Open command prompt in windows and run this command: ikvmc.exe -out:.dll .jar
  3. Above steps should generate the DLL which you can reference in C# project.

There is also another way using JNI4NET - https://github.com/jni4net/jni4net/ but I haven't explored it much as I was able to achieve what I want using iKVM

Happy Coding!

Thanks

Upvotes: 1

Related Questions