JLCA Ports Legacy Java Code to .NET

JLCA Ports Legacy Java Code to .NET

ava and .NET have each enjoyed a period in the sun as the hottest programming technology. Java is still a big favorite in enterprises—and justifiably so: Java runtime environments exist for all major platforms and even for simple embedded devices like mobile phones and BlackBerrys. Meanwhile, the .NET solution has many compelling advantages, including the ease of entry for existing Visual Basic programmers and a far more uniform method of configuration. Early surveys show C# in particular striking a popular chord with programmers, bringing new blood into the .NET world.

Happily for developers who need to migrate their enterprise Java applications to the .NET platform, the Java Language Conversion Assistant (JLCA) enables them to take legacy Java code and bring it into the .NET world as well.

For single developers and many small-to-medium-sized enterprises, especially, the Microsoft solution is the pragmatic choice. A search of employment Web sites anecdotally suggests it is easier to find programming talent that is familiar with Microsoft technology, and the large bevy of existing Visual Basic and Visual C++ code can be easily ported to the .NET environment as well.

This article introduces the JLCA and steps you through its installation and conversion process. The instructions include adding any missing components from the original Visual Studio.NET discs.

What Is the JLCA?
The JLCA is a free tool from Microsoft that automates the conversion of Java projects to C#.NET projects. Although it costs nothing and is simple to use, the JLCA can’t be used with free command-line C# compilers. It snaps only into Visual Studio.NET.

Microsoft’s official line is that the JLCA is part of its program to help former J++ programmers wean themselves off the Microsoft Java Virtual Machine (the non-standard JVM that caused much legal wrangling with Sun). Cynics will quickly note that the JLCA does not migrate code from Microsoft’s JVM to another JVM, but to the .NET framework instead.

Downloading and installing the JLCA is a snap. The current stable release is version 2.0 (JLCA 2). The current beta release is version 3.0 (JLCA 3), which is available by signing up with Microsoft’s Beta services at (enter JLCA3 as the beta program to participate in). The beta site has a nice download manager to ensure that downloads resume easily if transmission problems occur. Help files, which are well recommended, are available as a separate download.

Download JLCA 3 and its help files.

Figure 1: A Snap to Install
Figure 2: Deceptively Simple to Install

Large organizations such as Random House and InfoSys have already used JLCA 2 to convert existing servlet and JSP applications and Web sites to .NET. It can’t handle much more beyond these conversions, but JLCA 3 promises full J2EE support.

Don’t install JLCA 3 straight away after downloading it! The JLCA 3 beta does not include all the necessary files. It uses routines that date all the way back to the first version of the JLCA (which was included on the Visual Studio.NET 2003 CDs). If you have not installed JLCA 1 already, you need to before proceeding. You’ll find it under the C# installation options on the Visual Studio.NET 2003 CDs. Run the Visual Studio.NET setup just like normal and expand the C# options to locate the JLCA. If it is unchecked, then check it and click OK to have Windows install it.

Figure 3: JLCA 3 Doesn’t Include All Necessary Files
Figure 4: Install the Original JLCA 1

Install JLCA 3 now. Run the newly downloaded Windows Installer (msi) package. Apart from agreeing to Microsoft’s license terms, there are no prompts or dialogs—everything installs to the same locations as Visual Studio.NET (of course, if you don’t have Visual Studio.NET installed, then the JLCA 3 installation cannot proceed).

When you start Visual Studio.NET for the first time, it won’t be immediately obvious that anything has changed. It will not display any new icons or any new project types. Instead, it hides a “Convert” option under the File/Open menu—and that’s where you’ll find the JLCA.

Conversion Time
Start the JLCA. The wizard first prompts you to specify whether the Java code to be converted is an existing Microsoft J++ project or a directory of Java source code files (you can convert multiple paths in one process). One problem is you cannot choose individual files within a directory. Therefore, a directory containing multiple individual Java programs, each with its own main method, can result in conversion confusion as the JLCA pools them all into one resultant C# app.

The wizard next asks which type of C# project to create (Windows application, Web application, or others), what name to give the project, and where to find its output directory. And that’s all! Click “Finish” and the JLCA powers along by itself.

Despite the simple preceding steps, the conversion is a sophisticated process. It doesn’t just convert files one-by-one, merely substituting Java methods and library calls for their .NET equivalents. Rather, the JLCA carefully and intelligently analyzes the body of code to be converted and performs large-scale architectural rewrites. For instance, it converts:

  • Enterprise Java Beans (EJB) into COM components
  • AWT and Swing forms into Windows (or Web) forms
  • Remote Method Invocation (RMI) calls into .NET remoting calls
Figure 5: Conversion Process in Progress
Figure 6: The JLCA Has Done the Bulk of the Work

At completion, the JLCA gives a status report showing the total number of “issues” (warnings, errors, and the like) it found. The bulk of these findings are purely “just in case” alerts. For example, method calls may work slightly differently between C# and Java, in which case you need to check the “before” and “after” calls. However, the likelihood is that all the converted code will perform as expected except in rare situations.

The generated output code is clean and functional, and it demonstrates no trace of its Java origins. The JLCA intersperses comments wherever it raises issues, and these handily tie in with the IDE’s “To Do list” functionality, meaning you can easily find them.

Figure 7: Issues the JLCA Reports Are Likely Insignificant
Figure 8: Transported Java App with No Trace of Its Origins

A Java Conversion Tool for All Conversions
Porting an application between differing programming languages is no easy feat. The JLCA does an admirable job. Given the platform-neutrality of Java, the JLCA even enables you to port applications from different operating systems—from, say, Linux to Windows. The resulting code is genuine C#, using C# frameworks and components. Microsoft easily could have made a set of Java library “wrappers” that would have added additional execution overhead, but instead Redmond provided the JLCA to convert code to sensible C# equivalents where possible.

Naturally, all Microsoft-specific Java extensions (those that caused all the problems in the first place!) convert perfectly, but the JLCA also offers the following conversions:

  • As stated previously, EJB to COM components
  • JDBC database to ODBC
  • JSP code to ASP
  • JNDI code to .NET directory services

In fact, the JLCA 3 migrates the bulk of J2EE enterprise facilities, including CORBA, XML processing, GUI, and messaging components. Previous attempts at conversion tools from various vendors have balked at such features. I expected the JLCA to struggle with code that typically confused earlier Java conversion tools, such as native methods and RMI. Yet, the JLCA handled these with ease. Consequently, the JLCA is a tremendous boon to developers who wish to migrate serious applications from Java to the .NET arena. It is sure to be a relief to stranded Visual J++ programmers who want to build on their old code—despite the death of J++. And because it supports the whole J2EE platform, it is powerful enough to bring large-scale enterprise applications into the Microsoft fold.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist