Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an effective tool to convert C# code to Java code? [duplicate]

People also ask

Can you convert C# to Java?

To convert a C# snippet, we paste the code into the left editor and click on the Convert button. After clicking the Convert button, the tool converts the C# code to Java and shows it on the right editor. We can save this in a file using the Save button or copy it.

How do I convert a C++ code to C Is there an online converter?

It is technically impossible to convert C++ code to C code because both languages although seem similar work very differently at binary level. Also, C does not support any aspect of object oriented programming and thus have no “C++ equivalent”.


I have never encountered a C#->Java conversion tool. The syntax would be easy enough, but the frameworks are dramatically different. Even if there were a tool, I would strongly advise against it. I have worked on several "migration" projects, and can't say emphatically enough that while conversion seems like a good choice, conversion projects always always always turn in to money pits. It's not a shortcut, what you end up with is code that is not readable, and doesn't take advantage of the target language. speaking from personal experience, assume that a rewrite is the cheaper option.


We have an application that we need to maintain in both C# and Java. Since we actively maintain this product, a one-time port wasn't an option. We investigated Net2Java and the Mainsoft tools, but neither met our requirements (Net2Java for lack of robustness and Mainsoft for cost and lack of source code conversion). We created our own tool called CS2J that runs as part of our nightly build script and does a very effective port of our C# code to Java. Right now it is precisely good enough to translate our application, but would have a long way to go before being considered a comprehensive tool. We've licensed the technology to a few parties with similar needs and we're toying with the idea of releasing it publicly, but our core business just keeps us too busy these days.


This blog post suggests useful results from Tangible.


There is a tool from Microsoft to convert java to C#. For the opposite direction take a look here and here. If this doesn't work out, it should not take too long to convert the source manually because C# and java are very similar,


These guys seem to have a solution for this, but I haven't tried yet. They also have a demo version of the converter.


Although this is an old-ish question, take a look at xmlVM http://www.xmlvm.org/clr2jvm, I'm not sure if it's mature enough yet, although it has been around for several years now. XMLvm was made, I believe, primarily for translating Android Java apps to the iPhone, however, its XML-code-translation-based framework is flexible enough to do other combinations (see the diagrams on the site).

As for a reason to do this conversion, maybe there is a need to 'hijack' some of the highly abundant oss code out there and use it within his/their own [Java] project.

Cheers

Rich