28

We've developed a Java application and would like to use this application from a C# client. The application has dependencies on Spring, Log4j, ...

What would be the most efficient mechanism - make DLL(s) from Java code, ... - to achieve this ?

2
  • Possible duplicate of Using Java-classes with C# Commented Aug 14, 2016 at 20:23
  • Hi, What is recommended by you now ? Commented Jun 18, 2020 at 16:57

4 Answers 4

31

IKVM!

It is really awesome. The only problem is that it DOES add ~30MB to the project. log4net and Spring .NET are available as well, but if living with existing code, go the ikvm route.

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

1 Comment

In the latest version of IKVM, the JDK library is broken out into separate assemblies. Depending on what you need, you probably won't have the full 30MB of baggage anymore. The jdk core assembly is about 5 MB.
15

I am author of jni4net, open source interprocess bridge between JVM and CLR. It's build on top of JNI and PInvoke. No C/C++ code needed. I hope it will help you.

2 Comments

Hi Pavel, Does the jni4net framework works in the Linux environment now?
Thanks, Pavel, Can you recommend what can I use to call the Java from my .net core, please. Do you think C++ wrapper is viable?
2

alternatively you could write a webservice/xmlrpc layer between the two.

I seem to remember that there is a tool calles grassshopper that will compile your .Net code into JVM bytecode.

I've also heard good things about IKVM

Comments

2

There are so many options,

  1. sockets

  2. web services

  3. Message bus

  4. Use a/any database! (sorry if sound silly)

Here's a discussion which may be handy: https://gridwizard.wordpress.com/2015/01/14/java-and-dotnet-interop

Really depends on what you're building!

2 Comments

The OP specifically requested 'calling'. All the approaches you identify involve 'sending messages'. The last - database - option is arguably even less direct by requiring polling of a staging table.
Would add to the list gRPC streaming with proto3.

Your Answer

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