Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using dlls written in C# in Java Project

Tags:

java

c#

dll

I'm working on a Java project and I'm not very familiar with using Java I usually use C# with aforge for my computer vision projects now I have to use Java and I want to use the aforge DLLs which are written in C# is there a way to do this ?

Thank you

like image 473
Nawwar Avatar asked Apr 11 '11 08:04

Nawwar


2 Answers

It is possible, but you'll need to do some work to get them calling properly. I've never done it myself, but until someone better equipped to answer the question comes along here's a few places to start.

Take a look at the JNI (Java Native Interface, google or wikipedia can tell you more), which lets you call out from Java to other languages. There seems to be a project called jni4net ( http://jni4net.sourceforge.net ) which is intended to do exactly what you want, but it's in alpha at the moment and might not be stable enough. Still it could be worth having a look.

You can also do it yourself, calling through the JNI as a C call which will then get through to the CLR eventually, but it looks like a lot of effort. I know this isn't a quick and easy solution, but it might give you a couple of places to get started. also http://www.codeproject.com/KB/cross-platform/javacsharp.aspx seemed to be a fairly good look at how to go about it.

As all of the other answers so far have said though, it's fiddly and a pain. If you can do something else instead, it will probably be worth it.

like image 60
Ben Avatar answered Sep 23 '22 03:09

Ben


Have a look at Jni4Net and this stack overflow question: is there an effective tool to convert c# to java?

like image 44
Ralph Avatar answered Sep 23 '22 03:09

Ralph