如何从C#调用Java代码?

时间:2021-02-14 15:06: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, ...

我们开发了一个Java应用程序,并希望从C#客户端使用这个应用程序。该应用程序依赖于Spring,Log4j,...

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

什么是最有效的机制 - 从Java代码生成DLL,... - 实现这一目标?

4 个解决方案

#1


24  

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.

真的很棒。唯一的问题是它可以为项目增加约30MB。 log4net和Spring .NET也可用,但如果使用现有代码,请转到ikvm路由。

#2


11  

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.

我是jni4net的作者,jVM和CLR之间的开源进程间桥接。它建立在JNI和PInvoke之上。不需要C / C ++代码。我希望它会对你有所帮助。

#3


2  

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

或者你可以在两者之间写一个webservice / xmlrpc层。

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

我似乎记得有一个工具calles grassshopper将你的.Net代码编译成JVM字节码。

I've also heard good things about IKVM

我也听说过有关IKVM的好消息

#4


0  

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

这是一个可能很方便的讨论:https://gridwizard.wordpress.com/2015/01/14/java-and-dotnet-interop

Really depends on what you're building!

真的取决于你正在建设什么!

#1


24  

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.

真的很棒。唯一的问题是它可以为项目增加约30MB。 log4net和Spring .NET也可用,但如果使用现有代码,请转到ikvm路由。

#2


11  

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.

我是jni4net的作者,jVM和CLR之间的开源进程间桥接。它建立在JNI和PInvoke之上。不需要C / C ++代码。我希望它会对你有所帮助。

#3


2  

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

或者你可以在两者之间写一个webservice / xmlrpc层。

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

我似乎记得有一个工具calles grassshopper将你的.Net代码编译成JVM字节码。

I've also heard good things about IKVM

我也听说过有关IKVM的好消息

#4


0  

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

这是一个可能很方便的讨论:https://gridwizard.wordpress.com/2015/01/14/java-and-dotnet-interop

Really depends on what you're building!

真的取决于你正在建设什么!