Why doesn't Sun do a C# to Java byte code compiler?

后端 未结 18 1864
清酒与你
清酒与你 2021-02-01 01:20

We Want to Run Our C# Code on the JVM

My company has a large C# code base. Well over half of this code is our core engine for creating, reading, modifying, calculating

相关标签:
18条回答
  • 2021-02-01 01:57

    You can run your .NET code and Java code in the same interpreter! See the IKVM .NET-based JVM, and the Boo and Java wiki page for an example use case (using the .NET-based Boo language to write applications using Java libraries).

    0 讨论(0)
  • 2021-02-01 01:57

    Joe, I suggest you investigate IKVM. You might find something there that scratches your itch

    0 讨论(0)
  • 2021-02-01 01:58

    Why doesn't Microsoft do a C# to Java byte code compiler? Why don't you do it? There are open specs on each side...

    0 讨论(0)
  • 2021-02-01 02:00

    I wonder whether the Mono project could have made less work for themselves by targeting the JVM instead of developing and maintaining their own virtual machine from scratch. Development effort could have focused on a C# cross-compiler and porting clean-room implementations of the .NET libraries to the JVM. Sort of like an open-source version of what Mainsoft has done. You could then enable inter-language calls between Java and C# code in the same JVM, and deploy Applets and Java Web Start applications written in C#.

    0 讨论(0)
  • 2021-02-01 02:02

    Firstly Sun has zero incentive to implement a C# compiler on the JVM because they have something very similar called the Java programming language.

    Its also not really as simple as just implementing a compiler as the Java standard class libraries are not the same as the .net Base Class Libraries. You would end up having to change all the .NET API calls to Java API calls.

    Micrsoft had a product called J# which was meant to be for Java to .NET conversion but in the end no one used it as the API was limited to pre Java 2 API so it was mostly useless. It would be the same if Sun implemented parts of the .NET BCL, as only the core portions of it are standardised and royalty free. Parts like ASP.NET and WPF, WCF etc are not part of the ECMA standards and so Sun would need Microsofts permission to implement those API's.

    If enough customers want a java version to make business sense to port your application to java then do it, you just wont ever get any help from Sun via a C# to JVM compiler.

    0 讨论(0)
  • 2021-02-01 02:04

    Expose your .NET API as ASMX web services and you should be good to go.

    EDIT: For more heavy-usage scenarios, it would be worth looking into Windows Communication Foundation (WCF). This has built-in, configurable support for security, streaming, different transport scenarios (HTTP, TCP/IP, local named pipes). You are not restricted to SOAP message encoding, but that would probably be the easiest way to interop with Java.

    I'm not too sure about your exact scenario, but if you're dealing with large files and the .NET code and Java code are both running locally, you can just save the file to the user's hard drive using .NET and then fetch it from your Java app.

    0 讨论(0)
提交回复
热议问题