3

As the title states, I'm looking for a basic (working) tutorial of Java code that uses JNI to call a "hello world" kind of application written in C#.

The "best" I found is this, but I can't get it to work following the tutorial + the ready to use projects don't build in Visual Studio 2008.

I have to say that I have no .NET knowledge apart from creating a basic project and writing C# code. Once I have working projects I'll do something similar with the DLL (and source code) I received.

Thank you for your time.

1 Answer 1

6

Sounds like jni4net may be of use ? From the intro page:

import net.sf.jni4net.Bridge;
import java.io.IOException;
import java.lang.String;

public class Program {
    public static void main(String[] args) throws IOException {
        Bridge.init();
        system.Console.WriteLine("Greetings from Java to .NET world!");
    }
}

So it looks pretty straightforward. Of course the devil is in the detail.

4
  • I already saw that, but I didn't want to add an extra layer of abstraction just to expose a few (10 - 20) C# methods to Java. Now that it seems impossible to find a basic working "hello world" example, I'll stick with this, thanks! Jul 10, 2011 at 11:33
  • 1
    I have compiled this tutorial from my java-.net bridging experience, Hope it helps : codefry.blogspot.in/2012/01/… Apr 10, 2013 at 18:36
  • Does invoking C# code from java mean I can also access C# libraries from java?
    – Lealo
    Jan 11, 2018 at 1:16
  • I would believe so, yes Jan 11, 2018 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.