简体   繁体   中英

Call C# mono code from java under linux

I have somoe C# source code that I want to be available for java applications under linux OS.

How can I call some C# method from java code?

I have found http://www.mono-project.com/Java but this looks like writing java code in .net environment. It is not what I look for. Rather I need to create new java library that will expose all functionality from C# code, the new library must be executed in pure java environment. Maybe that is possible with IKVM I am not sure.

  1. Use Mono to compile your C# classes on the Linux platform of your choice;
  2. Use JNI to write a set of facade classes between your java code and the compiled C# code.

The closest tool I can find that might be useful would be JNI4Net

I think you would still need Mono to run a .net framework on Linux as well.

Your question is going to be closed (I voted too) simply because it would finally lead to a tool recommendation.

Your best approach is to rewrite them in Java. Or alternatively, there are existing tools (commercial or free) to convert C# to Java,

Mono is not something you should consider at this moment. Yes, IKVM.NET only helps running Java code on Mono/.NET, and it won't help you in your case.

It's not clear if you can execute the c# project or not through mono, if you can, then process intercomunication is the way to go.

If you are doing it in Linux I should use a pipe channeling to intercomunicate both processes, works really well and is easy to use.

If you can't execute the c# process, then that's another history, you cannot call directly a .net assembly from java.

And also, using mono on Linux per today gives great results (except for ASP .net), we are using it and are getting really good results (faster responses than Java in most scenarios).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM