Developer's Toolkit
Visual Studio and Java?
Using Mainsoft for Enterprise Edition, Visual Studio developers can write code in .NET and cross-compile it to Java.
- By Peter Varhol
- 06/01/2008
For many, the use of .NET or Java is an either/or decision. If you use .NET, you get the advantage of the best IDE in the business, but you're stuck with writing mostly in C# -- or VB.NET or possibly C++ -- and deploying on Windows. The language choice isn't that bad -- there are 20 or so other lesser languages available from Microsoft or third parties.
But the deployment lock-in can still hurt. While Microsoft continues to make advances in server software, you don't have the flexibility to consider other platforms. The popular one for Web applications of all types today is Linux, where you're not faced with the complex and often-expensive licensing rules that cover Windows. Alternatively, some enterprise data centers require certain platforms for support reasons, and sometimes the supported platforms don't include Windows.
You used to be able to use Visual Studio for Java development, back when there was such a thing as J++. I still have my good friend Andy Wilson's book, "Network Programming with Microsoft Visual J++ 6.0" (Microsoft Press, 1998). But that went away when Sun accused Microsoft of adding to the language, something that was strictly prohibited by licensing -- which, ironically, is permissible now that Java uses the open source GNU General Public License. If Microsoft had stuck with Java, or returned to it under the new license -- though that train has likely left the station -- it might have been easy to deploy on other servers.
The alternative for more deployment freedom is to invest in Java skills. Thanks in part to the efforts of The Eclipse Foundation, IDEs and other application development and testing tools tend to be less expensive or even free. However, their feature sets and ease of use are often not up to the high standards set by Visual Studio.
Write in C#, Deploy in Java
There is a way of marrying the advantages of .NET development with Java deployment. Using Mainsoft for Enterprise Edition (EE), Visual Studio developers can write code in .NET and cross-compile it to Java. Not only code, but pieces of the Framework; Mainsoft has worked with Miguel de Icaza and Novell to port pieces of the Mono project to Java. Your limits in calling Framework classes, especially for Web apps, are almost nonexistent.
Mainsoft is a plug-in to Visual Studio. To use, you simply take a buildable ASP.NET project -- ASP.NET because Java is mostly used in Web apps -- and target a Java project. You can even use the Visual Studio debugger to assist in debugging the Java code after the translation is complete. The Mainsoft translator cross-compiles back to .NET on the fly for the purposes of debugging. If you get a clean translation, a moderately simple ASP.NET application can be up and running in Java in about five minutes. Sometimes you have to make some adjustments in the translation, but in general, Mainsoft does a remarkable job of producing a buildable Java EE application.
.NET Apps on WebSphere
A nice feature of the new portal version of Mainsoft is that you can take applications written for SharePoint and target IBM's WebSphere Portal. Mainsoft SharePoint Federator enables Microsoft developers to use Visual Studio to take .NET applications, including those applications targeting Windows SharePoint Services, to run natively on WebSphere Portal.
Mainsoft SharePoint Federator for WebSphere Portal takes the application and translates it into native Java, then integrates it as a WebSphere Portlet. It can also integrate Microsoft-specific classes into the resulting Java application through the translation of those classes into Java. This lets enterprises leverage SharePoint content and applications used at the department level into an enterprise WebSphere Portal.
Microsoft developers using Visual Studio can target the WebSphere Portal simply by writing and building the application using the Microsoft technologies they use daily, and invoking the translation after development is complete and the application builds as a Microsoft program. Even application maintenance can be done in C#, and the enhancements or bug fixes can be translated into Java for deployment.
Windows Server is an acceptable deployment solution for many applications. But I've come across enterprises where .NET development is done for line-of-business applications, yet IT supports only Unix in the enterprise data center. It may be due to skills, or capacity, or culture, but just as there are Microsoft-only data centers, there are also Java-only data centers. As far as I can tell, the .NET-to-Java translation that Mainsoft enables is both unique and fun to use. If the idea of writing in .NET and deploying in Java intrigues you, the Mainsoft Developer Edition can be downloaded and freely used at
http://dev.mainsoft.com
.
About the Author
Peter Varhol is the executive editor,
reviews of Redmond magazine and has more than 20 years of experience as a software
developer, software product manager and technology writer. He has graduate degrees
in computer science and mathematics, and has taught both subjects at the university
level.