7

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).

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

4 Comments

How can IKVM helps here, the resolution should be made in runtime and not by creating static artifacts (.NET proxies)?
@Guy - IKVM can be used in both dynamic and static modes; see sourceforge.net/apps/mediawiki/ikvm/… In dynamic mode, Java bytecodes are translated on the fly into CIL by the class loader.
Being more general, I want to draw away from the solution that creates .NET proxy.
The dynamic mode is just as calling Java.exe and can be applied on java programs (i.e. with main(String[]) ). Not good for me.
3

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#.

2 Comments

I didn't mention that I don't have any clue regarding the Java code nor any possibility to change it. The only input I have is: JAR, method name, arguments and values
dbenerlin : What are complex data types supported in Java which are supported in .Net ? Thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.