Abhi4ever
Abhi4ever

Reputation: 41

Create a .dll file of java from the .net dll

I am really struck at this point.

I have a .dll that is written .net and which is created using SWIG(http://www.swig.org/). No my goal is to use the dll in java.

So my questions are

  1. Can I use the dll file directly? i.e. is the dll file independent on the language in which it is written??

if not , What is the best way to re-write/port the dll to java?

  1. How can i create Export functions that i can use directly from my java code after initializing this dll.

Thanks for the try!

Upvotes: 0

Views: 1718

Answers (2)

linuxuser27
linuxuser27

Reputation: 7353

Unfortunately someone already suggested this and deleted it, but it is a valid solution and probably the best one.

  1. Use JNI to create an interface from your Java code to native
  2. Using the .NET hosting API load the .NET Runtime into your Java process
  3. The .NET Runtime can now be used to load your .NET DLL
  4. From your Java code call into your JNI layer in native and then into the .NET DLL

Upvotes: 0

Jayan
Jayan

Reputation: 18468

One solution is using JNI. I have used JNA to call windows API (not .net though). You may check some examples.

Upvotes: 1

Related Questions