tags:

views:

2435

answers:

7

I needed to convert a Java 1.5se app to C# 2.0.

Does anyone know of a tool (preferably free/open source) to do this?

+18  A: 

Even if there is such a tool, I'd highly recommend you to do the conversion by hand. Automatic converters will often faithfully reproduce the code, but ignore idioms - because they'd be really, really hard to get right.

Furthermore, the differences between generics in .NET and Java could lead to some very different decisions in the two codebases.

Really, you'll be better off doing it by hand.

Jon Skeet
I agree. I did look at the Java Language Conversion Assistant for a relatively small project and the clean-up work needed after the conversion was not significantly smaller than the work needed for a rewrite.
Brian Rasmussen
Ditto, but more than once despite emphatically warning the respective clients.
Michael Meadows
+1  A: 

How long do you have? The universal dovetailing algorithm will do it.... yeah or jon. I guess he can run the universal dovetailing time quicker than a quantum computer.

Jesse Pepper
+6  A: 

Java Language Conversion Assistant. Optionally installed with (at least) Visual Studio 2005 Standard Edition.

Select File/Open/Convert/Java Language Conversion Assistant.

Remember to manually go over the code afterwards. It will have lots of issues.

Rasmus Faber
Is there any other alternative in conversion of Java to C#? I've successfully use VS2005 to convert Java code to C# with not too many modifications by hand and I really like it.
m3rLinEz
Not only will it have issues at the implementation level, but it won't be designed in a .NET-idiomatic way. Again I say, hand-porting...
Jon Skeet
The tool rocks!! Thanks
CSharpDevLondon
Hand conversion is always required, but a lot of code can go over as is. Replacing small syntax differences like uses of final, checked exceptions, and synchronized goes a long way when porting.
Eric Hauser
doesnt appear to be around in vs2010 though?
boomhauer
+1  A: 

Microsoft used to have their own Java to C# Converter - Microsoft Java Language Conversion Assistant 3.0

revs
doesnt seem to be available for download though?
boomhauer
+3  A: 

ikvm exposes java classes in .NET. Its not a converter, but based on my experience I'd recommend it to anyone making the transition from java to .NET