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

<p>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.</p>

<p>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.</p>

<p>Thanks.</p>

[{'answer_id': 65080, 'author': 'ordnungswidrig', 'author_id': 9069, 'author_profile': 'https://Stackoverflow.com/users/9069', 'pm_score': 0, 'selected': False, 'text': '<p>I only know the other way. <a href="http://www.db4o.com/" rel="nofollow noreferrer">Dbo4</a> is developed in java and the c# version is generated from the java sources automaticaly.</p>\n'}, {'answer_id': 65084, 'author': 'Nick Berardi', 'author_id': 17, 'author_profile': 'https://Stackoverflow.com/users/17', 'pm_score': 0, 'selected': False, 'text': '<p>There is no good way.  My recommendation is to start over in Java, or like you said use Mono.</p>\n'}, {'answer_id': 65090, 'author': 'Thomas Owens', 'author_id': 572, 'author_profile': 'https://Stackoverflow.com/users/572', 'pm_score': 0, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 65094, 'author': 'Nate Kohari', 'author_id': 1282, 'author_profile': 'https://Stackoverflow.com/users/1282', 'pm_score': 4, 'selected': True, 'text': '<p>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 <a href="http://dev.mainsoft.com/Default.aspx?tabid=130" rel="noreferrer">Grasshopper</a>. It\'s a commercial product, but it claims to be able to translate CIL (the output of the C# compiler) to Java bytecodes.</p>\n'}, {'answer_id': 65139, 'author': 'Brian Phillips', 'author_id': 7230, 'author_profile': 'https://Stackoverflow.com/users/7230', 'pm_score': 2, 'selected': False, 'text': '<p>Possible solutions aside, direct translations of programs written in one language to a different language is generally considered a Bad Idea&trade; -- especially if this translation is done in some automated fashion.  Even when done by a "real" programmer, translating an application line by line often results in a less than desirable end result because each language has its own idioms, strengths and weaknesses that require things be done in a slightly different way.</p>\n\n<p>As painful as it may be, it\'s probably in your best interest and those who have to maintain this application to rewrite it in Java if that\'s what your employer requires.</p>\n'}, {'answer_id': 65154, 'author': 'EricSchaefer', 'author_id': 8976, 'author_profile': 'https://Stackoverflow.com/users/8976', 'pm_score': 0, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 65315, 'author': 'jsight', 'author_id': 1432, 'author_profile': 'https://Stackoverflow.com/users/1432', 'pm_score': 0, 'selected': False, 'text': "<p>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.</p>\n\n<p>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.  :)</p>\n"}, {'answer_id': 72998, 'author': 'Alfonso Pajares', 'author_id': 12369, 'author_profile': 'https://Stackoverflow.com/users/12369', 'pm_score': 0, 'selected': False, 'text': '<p>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.</p>\n'}]
['https://Stackoverflow.com/questions/65058', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8315/']