Is there an effective tool for converting C # code to Java code?

Is there an effective tool for converting C # code to Java code?

+78
java c # code-translation
Sep 17 '08 at 1:04
source share
14 answers

I have never come across a C # → Java conversion tool. The syntax will be quite simple, but the scope is significantly different. Even if there was a tool, I would strongly advise him. I have worked on several “migration” projects and I can’t say decisively enough that although conversion seems like a good choice, conversion projects are always always included in money pits. This is not a shortcut, what you get is code that cannot be read and does not use the target language. speaking first hand, suppose rewriting is a cheaper option.

+42
Sep 17 '08 at 1:30
source share

We have an application that we need to support in both C # and Java. Since we actively support this product, a one-time port was not an option. We investigated the Net2Java and Mainsoft tools, but did not meet our requirements (Net2Java due to lack of reliability and Mainsoft for cost and lack of source code conversion). We created our own CS2J tool that works as part of our nightly build script and makes a very efficient port of our C # Java code. Now it’s good enough to translate our application, but it has a long way to go before considering it as a comprehensive tool. We licensed the technology to several parties with similar needs, and we play with the idea of ​​publishing it publicly, but our core business just makes us get too busy these days.

+25
Aug 03 '09 at 2:00
source share

This post blog offers useful tangible results.

+7
Apr 10 2018-10-10T00:
source share

There is a tool from Microsoft for converting java to C #. In the opposite direction, look here and here . If this does not work, it does not take too long to convert the source text manually, because C # and java are very similar.

+5
Sep 17 '08 at 1:27
source share

Although this is an old question, see xmlVM http://www.xmlvm.org/clr2jvm , I'm not sure if it is mature enough, although it has been around for several years. XMLvm was made, I believe, primarily for translating Android Java applications on the iPhone, however, its XML-based code structure is flexible enough to perform other combinations (see. Charts on the site).

Regarding the reason for this conversion, perhaps there is a need to “grab” some of the very rich oss code there and use it in your / your own [Java] project.

Greetings

Rich

+4
Jan 13 '11 at 16:47
source share

They do not translate directly, but allow interoperability between .NET and J2EE.

http://www.mainsoft.com/products/index.aspx

+2
Sep 17 '08 at 1:13
source share

C # has a few more features besides Java. Take delegates, for example: many very simple C # applications use delegates, while people from Java indicate that the observer pattern was sufficient. Thus, in order for a tool to convert a C # application that delegates use, it would have to transfer the structure from using delegates to the implementation of the observer pattern. Another problem is that C # methods are not virtual by default, while Java methods. In addition, Java has no way to make methods non-virtual. This creates another problem: a C # application can use the behavior of a non-virtual method through polymorphism, since it does not translate directly to Java. If you look around, you will probably find that there are many tools for converting Java to C #, since it is a simpler language (please do not flame me, I did not say what I said easier); however, you will find very few if any decent tools that convert C # to Java.

I would recommend changing your approach to converting from Java to C #, as it will create fewer headaches in the long run. Recently, Db4Objects have released their internal tool that they use to convert Db4o to C # to the public. This is called Sharpen. If you register on your site, you can view this link with instructions for using Sharpen: http://developer.db4o.com/Resources/view.aspx/Reference/Sharpen/How_To_Setup_Sharpen

(I was registered with them for a while, and they do not like spam)

+2
Sep 17 '08 at 1:57
source share

Try looking at Net2Java. It seems to me the best option for automatic (or semi-automatic) conversion from C # to Java

+2
Jan 12 '09 at 16:39
source share

This is off the cuff, but it's not what Grasshopper is for?

+1
Nov 13 '08 at 14:48
source share

I'm not sure what you are trying to do, wanting to convert C # to java, but if this is the .net interoperability you need, you can check Mono

0
Nov 13 '08 at 14:45
source share

Well, the syntax is pretty much the same, but they rely on different structures, so the only way to convert is to get someone who knows both languages ​​and translate the code :) the answer to your question: there is no "effective" tool for converting C # to java

0
Aug 03 '09 at 14:04
source share

Perhaps you could use jni4net - bridgeource instead . Or a list of other options I know.

0
Dec 13 '10 at 23:57
source share

Why not write it to HAXE ( http://haxe.org/ ) and convert it to what you want?

-2
Aug 27 '15 at 6:59
source share



All Articles