Geeks With Blogs
Chaz Blogs It's all about the eXperience!

I am working on a port of an opensource domain specific Time & Money java library written by Eric Evans to .Net.  To the best of my knowledge there are 2 ways to directly convert Java to .Net;

1. Use the built in Convert function within Visual Studio 2005/08.  This lets you point directly at the java classes and allow studio to handle the conversion to C#.

2. Create a J# project, and include the java files in your project.

Using the first method there are a lot of conversion problems because a number of Java methods have no direct equivilant in .Net.  A typical error is java.util.Calendar.add could not be converted.  And since this domain is all about Time, there are a lot of these issues.

The second method is a little better, but still not great.  I was able to bring the java classes right into J#.   The only significant issue was that there were a ton of "asserts" in the code.  J# didn't handle it well, so I had to clean that up.  So my next step was to get it from J# to C#.  I copmpiled the J# and then used Reflector to reverse it to C#.  I didn't get everything I wanted.

Some classes are decorated like this;


I was hoping for a complete break from Java.  I guess I will have to do this port the old fashion way.  I'll have to understand exactly what each module does and then write copy or write the C# equivilant accordinly. 

So much for getting away cheap and being lazy.  It was worth a try.  By the whole port exercise was very interesting.


JavaInterfaces("2;java/lang/Comparable;java/io/Serializable;")] Posted on Thursday, January 10, 2008 8:10 AM .Net | Back to top

Comments on this post: Options For Porting Java to .Net

# re: Options For Porting Java to .Net
Requesting Gravatar...
Have you tried using IKVM?
Left by Julian on Jan 11, 2008 1:59 PM

Your comment:
 (will show your gravatar)

Copyright © Chip Lemmon | Powered by: