eomeroff
eomeroff

Reputation: 9915

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.

Upvotes: 0

Views: 1462

Answers (4)

Steve C
Steve C

Reputation: 19445

  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.

Upvotes: 3

paisanco
paisanco

Reputation: 4164

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.

Upvotes: 1

Gusman
Gusman

Reputation: 15161

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

Upvotes: 0

Lex Li
Lex Li

Reputation: 63264

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.

Upvotes: 0

Related Questions