Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call any Java method from C#

Is there a way using JNI and C# code to create a program that invoke any given Java method? Assume that I have a jar containing classes hierarchy and I'm responsible for loading the JVM and these classes, can I write a C# program that receives the java method signature + arguments values on the fly and call the java code?

Please try to restrict your answers to free technologies (JNI solutions prefered).

like image 995
Guy Avatar asked Apr 07 '10 11:04

Guy


2 Answers

IKVM is one option. It implements a JVM in .Net and provides interop tools.

like image 183
Marcelo Cantos Avatar answered Oct 01 '22 03:10

Marcelo Cantos


IMHO the best way would be to run the Java Program as a WebService (or create a Java based WebService Interface for it) and just call it from C#.

like image 30
Morfildur Avatar answered Oct 01 '22 02:10

Morfildur