Download: Microsoft Tool Converts Java, JSPs for .NET
This week, Microsoft released for download its upgraded Java Language Conversion Assistant (JLCA) 2.0, a wizard-based tool that can automate the conversion of Java syntax and Java code to native Visual C# .NET. The key addition is JLCA's support for JSPs and servlets code. IDN takes a look at JLCA's features and talks with an early developer.
Microsoft's Java Language Conversion Assistant (JLCA) 2.0, is a wizard-based tool that can automate up to 80% of the process of migrating Java's language syntax and library calls from existing Java language source code into Visual C# .NET While JLCA 1.0 was directed at J++ developers, the current JLCA 2.0 version adds major support for converting Java Server Pages (JSPs) and servlet code to standard C# code.
"We have a lot of customers with mixed environments who use .NET and Java/JSP," said Tony Goodhew, product manager for Visual Studio.NET. "With this version of JLCA we can help them maximize their code investments by quickly migrating their Java applications to the .NET framework without the need to recode."
From 150,00 downloads of the first edition of JCLA, Microsoft received developer feedback and undertook to address it by add new features in JCLA 2.0. Among those were support for Java collection classes, JSP/servlets, Windows Foundation Classes and a Windows (client-side) abstracting toolkit, Dan Fernandez, Microsoft's Visual C#.NET product manager added.
Integrate, But Why Migrate?
Many enterprises will have both Java/J2EE and .NET development initiatives, and have a need to integrate those projects. But why would Java developers want to migrate their codebase to .NET?
"Most customers will have both J2EE and .NET in their organization," Goodhew said, "and we see many customers looking for ways to cost-effectively manage their code investments." Goodhew noted studies, including from Gartner Group, that note many J2EE users are not using their full capacity of the app server, and are in effect "overpaying for development and support because they are only using a minimal set of technologies, such as JSPs and servlets." With JLCA 2.0, "we can run those codesets on Windows in the .NET framework cheaper, and now we can migrate that code a lot easier so that companies can recover their coding investments," Goodhew said.
Even one early JLCA users, an author of developer guides for Java and J2EE, concedes there are times where migrating code from Java to .NET is worth the effort.
Rob McGovern is a senior project manager at Infusion Development Corp., a Java and .NET services firm based in New York, and co-founders of CodeNotes (with Random House publishers), a hybrid print/online technical book series for developers. He has used JLCA 2.0 to convert the CodeNotes Java-based website to .NET.
McGovern said "The CodeNotes web application, which for low-cost reasons, was Java built on Windows and SQL Server, made a lot of sense to move over. We looked at converting to .NET was that we were going for low-cost. Our problem in Java was that we had 5-6 different vendors for our website, each providing a different piece," he added.
Is it very common to use so many different Java vendors' products for one application? "It's very common in Java shops," McGovern said. "It just happens that way, especially in Java where you've got portability of code. You often go to components or layers that come from different companies, because you're joist going with what works. In development, that can be great. But you inherit a major maintenance headache, costs, consolidated licensing fees and even just keeping up with upgrades for all components that all come out at different times."
This mix-and-match environment can be especially challenging, McGovern added, "when one of your layers changes the security it applies, and you need to apply it to your other components."
"I'm not a religious Java fanatic to be frank, and I don't think most Java developers are. Mostly, we're just looking for the best and fastest ways to get things done, and now many of us need to look to lower our costs as well," McGovern said.
He said a notable reason for his decision to migrate Java code to ASP.NET was "JSP and Javascipt is the hardest code to maintain. We write it, test it, it breaks and then we have to figure out what's wrong. With ASP.NET, there are validation controls and better visibility into the code, which helps speed up maintenance."
Another feature McGovern liked was the JLCA conversion report. "After the wizard runs through, you'll get a real comprehensive conversion report that will highlight all the areas where the Java code might not have converted 100 percent," McGovern told IDN, which was very helpful is helping us quickly pinpoint where we needed to do some hand coding or follow-up testing."
Inside Java-to-C# Migration
While the JLCA wizard will convert upwards of 80% of JSPs, Java classes and servlets to C# code, the key to the Java-to-C# conversion is found in some key under-the-covers technology from Artinsoft, the same company responsible for building core technologies that help migrate Visual Basic code to VB.NET.
"We license a core engine from Artinsoft that can look at the underlying Java source code and make an abstract syntax tree [of the code] so that in the process of migration we create a language-independent representation of the intent of the programmer," Goodhew told IDN. Technically, the Artinsoft technology defines some 50,000 discrete mapping between what sets of Java/JSP code does and how C# code does it."
McGovern describes the process this way: "It's not enough to pick up just the syntactical changes in the code, you need to understand how the code is being used, and that's the key to the tree Artinsoft has developed for the wizard " Nonetheless, McGovern added, "C# isn't all that different from Java. Namespaces, for instance are fairly similar, if not identical. In addition, the Artinsoft technology will pick up all the Java web technologies, such as applets, servlets, JSPs, tag libraries."
For all the benefits of the wizard, McGovern cocedes the migration is not a simple one-button operation. "You don't just hit a button; there are some migration issues that you'll need to resolve by hand," McGovern said.
One such area is converting XML-related code, he said. "Java prefers the SAX and DOM approach, which has a bitstream that is the opposite of C#," McGovern said. "Sure, there is a similar thought approach [to XML[ by both languages, but the methods they use are different. But, if you start with cleanly designed code, the JLCA wizard can do upwards of 80-90% straight conversion and save tons of time and developer resources of recoding."
Microsoft's offers a "Migration Guide" which offers developers a lot of case study examples and patterns for easing conversion from Java to C#. The keys to successful migration break down into two (2) phases -- pre-migration and post-migration. They are:
Phase 1: Converting Java Code for Functional Equivalence
1. Code Analysis - Before converting, you must understand your starting point. Identifying critical functionality and potential trouble spots provides the basis for your conversion.
2. Convert with the JLCA and Establish Functional Equivalence - The Java Language Conversion Assistant will convert as much of your site as possible, and produce a comprehensive report of problem areas. The JLCA may successfully convert as much as 90% of your code; however, you will still need to act on any errors reported by the JLCA. The goal is to establish functional equivalence with your original Web site.
Phase 2 - Optimizing Your Site For ASP.NET
2. Best Practices - The last step in a conversion project is to evaluate your application and re-architect to take advantage of best practices. In this section, you will leverage material from Microsoft's Perscriptive Architecture Group to evaluate your site security, improve performance, and increase your scalability and stability.
Developers can get more tips from the Migration Guide, or to simply get a deeper view of the JCLA/Artinsoft technologies.
The JLCA 2.0 free download is available from MSDN as a plug-in to Visual Studio .NET toolkit.