PDA

View Full Version : Convert between C# and Java with CSharpJavaMerger




sindy55
Sep 20, 2009, 10:38 PM
CSharpJavaMerger is an open source tool. It provides common interfaces of C# and Java and enables you to write one set of code which can be used both by C# and Java.

Below is a method that can be used in both of C# and Java. In the sample, CString is a class defined in the CSharpJavaMerger Framework.

public void AddTwoValues()
{
try
{
CString strValue1 = m_mainForm.GetFirstTextBoxValue();
CString strValue2 = m_mainForm.GetSecondTextBoxValue();

int iValue1 = strValue1.ToInteger();
int iValue2 = strValue2.ToInteger();
int iResult = iValue1 + iValue2;
CString strShowResult = CString.ValueOf(iResult);
m_mainForm.ShowResult(strShowResult);
CString strSaveResult = new CString(strValue1.GetValue() + " + " + strValue2.GetValue() + " = " + strShowResult.GetValue() + "\n");
m_mainForm.SaveResult(strSaveResult);
}
catch (Exception ee)
{
m_mainForm.SaveResult(new CString(ee.Message + "\n"));
m_mainForm.ShowResult(new CString("Error"));
}
}

More info on CSharpJavaMerger: <snip>



rev316
Sep 20, 2009, 11:07 PM
Cool impL. The maintenance that will be needed is sorta a turn off. Nor does it guarantee to be taking advantage of its target language. I'm certainly going to check it out, but it's been my experience that these "migration" frameworks often produce unreadable/unreliable code IMHO.

sindy55
Sep 22, 2009, 01:21 AM
Thanks for your response. The tool was used in the real world development of SCM Anywhere, which is a commercial software configuration management solution. Also, you are welcome to join us to better the open source tool :).

Cheers.