4

Possible Duplicate:
is there an effective tool to convert c# to java?

I'm not very experienced with Java and have a lot of C# that I would like to translate into Java syntax so it would become compilable.

Reason: Android and Google Cloud

I know the API/Platforms have different structures, but lets say we dont need a 100% compability, but just to get "core functionalitet" translated. The GUI itself is one story of its own, as I've learned. But instead of rewriting every SWITCH-CASE, rebuild every Class etc. it would be nice to "map" the objects to Java equals and then do a recompile on the Android/Google platform.

I am sure there would be something that cant be translated as its a "C# only thing" - but just like every language is possible to generate .NET/MONO I thought there might be a Java -> .Net available too and therefore also a decompiler kinda thing?

So are there any easy ways to overcome this translation by Frameworks, SDK or other similar methods that will take 80-95% of the task automatically?

Community
  • 1
  • 1
BerggreenDK
  • 4,915
  • 9
  • 39
  • 61

3 Answers3

1

Have a look here: JSC.

But beside, there are some c# concepts which don't easyli translate into java.

paweloque
  • 18,466
  • 26
  • 80
  • 136
0

.NET and Mono are compatible because both are VMs that run C# code. Grasshopper claims to allow you to run .NET classes on the JVM, but I haven't used it. It won't work at all for Android because Android isn't the JVM, but rather Dalvik.

The differences between C# and Java are more than "structural" as you put it, and translating from one language to another is more complicated than I think you understand.

Mike Yockey
  • 4,565
  • 22
  • 41
  • I dont say the languages are equal, but want to reuse as much as possible and focus on the "last bits and pieces". So we can do 20% ajustment code in Java and rest would be converted. But I might be wrong. – BerggreenDK Jan 25 '11 at 14:07
0

I know Microsoft has a tool that's supposed to help convert Java to C#, but considering that a great many java applications reference libraries outside of the main system (apache being the most prominent example) this type of tool would be a monumental task.

C# also has data types that aren't supported at all in Java, such as unsigned types and stack-allocated objects. Writing translations from CLR to Java bytecode would be difficult indeed. And if you're using lambda functions in your code, kiss this idea goodbye.

Then there's the fact that not all language features in Java are available to the Davlik JVM.

I'm not a microsoft fanboy, but here's a comparison of the two languages that will give you an idea why I doubt this tool exists.

http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java

avgvstvs
  • 6,196
  • 6
  • 43
  • 74
  • oh but some of the tools exists alright I've just learned. I am not talking about a 100% solution, but just something that will take away most of the lame-redo-my-work stuff. Eg. backend code for business logic or class/structures would be nice to get automatically. The API stuff for a certain webserver is not what we are looking to translate as different platforms have different possibilities. But if you encapsulate these calls into more general business classes, then you just need to focus on those pr. platform. – BerggreenDK Jan 25 '11 at 14:14
  • Good luck in your search, friend. Have you considered implementing this logic as webservices in C# and then just calling what you need from client apps? I don't have your details, but this would seem a faster way to go. – avgvstvs Jan 25 '11 at 14:20