tags:

views:

1674

answers:

9

I start to write a client - server application using .net (C#) for both client and server side.

Unfortunately, my company refuse to pay for Windows licence on server box meaning that I need to rewrite my code in Java, or go to the Mono way.

Is there any good way to translate C# code in Java ? The server application used no .net specific feature, only cross language tools like Spring.net, Hibernate.net and log4net.

Thanks.

A: 

I only know the other way. Dbo4 is developed in java and the c# version is generated from the java sources automaticaly.

ordnungswidrig
A: 

There is no good way. My recommendation is to start over in Java, or like you said use Mono.

Nick Berardi
A: 

Although I think the first mistake was choosing an implementation language without ensuring a suitable deployment environment, there's nothing that can be done about that now. I would think the Mono way would be better. Having to rewrite code would only increase the cost of the project, especially if you already have a good amount of code written in C#. I, personally, try to avoid rewriting code whenever possible.

Thomas Owens
+4  A: 

I'd suggest building for Mono. You'll run into some gray area, but overall it's great. However, if you want to build for Java, you might check out Grasshopper. It's a commercial product, but it claims to be able to translate CIL (the output of the C# compiler) to Java bytecodes.

Nate Kohari
I know nothing about Grasshopper, but it sounds like a bad idea. If you have any intention of running and maintaining this app in Java, you are going to want the source in Java, not C#.
shsteimer
+3  A: 
Brian Phillips
A: 

Java and C# are pretty close in syntax and semantics. The real problem is the little differences. They will bite you when you dont expect it.

EricSchaefer
A: 

Grasshopper is really the best solution at this time, if the licensing works for you (the free version has some significant limitations). Its completely based on the Mono class libs (which are actually pretty good), but runs on top of standard Java VMs. Thats good as the Java VMs are generally a bit faster and more stable than Mono, in my experience. It does have more weaknesses than Mono when it comes to Forms/Graphics related APIs, as much of this hasn't been ported to Java from the Mono VM, however.

In the cases were it works, it can be wonderful, though. The performance is sometimes even better than when running the same code on MS's VM on Windows. :)

jsight
A: 

I would say from a maintance stand point rewrite the code. It's going to bring the initial cost of the projet up but would be less labor intensive later for whoever is looking at the code. Like previous posters stated anything automated like this can't do as good as a job as a "real" programmer and doing line by line converting won't help much either. You don't want to produce code later on that works but is hell to maintain.

Alfonso Pajares
+1  A: 

You may also check out CSharpJavaMerger, which is an open source tool. http://www.kevingao.net/csharp-java-conversion

Thanks.

Sindy
Seems a great unique tool, thanks.
programmernovice