Visual MainWin Crosses the .NET-Java Divide (
Page 1 of 2 )
We're impressed. We're really impressed. Creating applications for either Java or .NET is easy with Visual MainWin as a partner.
Developers sometimes think that .NET and Java is an either-or proposition. Creating an environment in which you can use your current .NET skills to produce great-looking Java code is the best way to overcome that .NET/Java divide. That's important to your career no matter what kind of programmer you are. Consultants who can offer clients a choice of either .NET or Java have twice the market of consultants who don't. Developers who can use more than one environment have a larger pool of jobs to choose from. And so on. Yet, enterprise teams made up of both Java and .NET developers require tools to create applications that work together.
Whatever your reason for wanting to create Java code using your .NET skills, Visual MainWin from MainSoft Corporation is a great answer. You can use this Visual Studio .NET add-in to create Java code without learning Java. Visual MainWin lets you use the skills you already know, rather than require you to reinvent the wheel.
ADVERTISEMENT
What Visual MainWin Provides
Visual MainWin provides developers with a lot of functionality. You can create applications using standard .NET code that ends up as Java, and to debug the result directly from the Visual Studio .NET IDE. One impressive feature is Visual MainWin's ability to use enterprise beans from servers, such as the J2EE Application Server and IBM WebSphere, as if they're .NET classes.
The Java developers on your team will never know that you used .NET to create the output they see. It's all very transparent, which makes mixed-team projects that were impossible yesterday, quite possible today. You can work on the Web applications you need to create, without worrying about the skill levels of other developers — a big help for enterprises looking to cut development costs.
As with most Visual Studio .NET add-ins, there are a few caveats. The biggest issue is that you can only create console and Web applications — no desktop application support. Considering that many developers are neck deep in Web application projects now and the number of desktop applications has (reportedly) decreased, this limitation probably won't affect many developers.
You use special Visual MainWin templates to create the Java applications. This issue isn't a big deal if you normally use unmodified versions of the Visual Studio .NET templates, as Visual MainSoft did an admirable job of making the templates compatible. I really did feel as if the templates didn't ask me to do anything the Microsoft templates didn't already expect. However, development shops that have customized their templates will run into problems. You have to customize the Visual MainWin templates to get the same results. This isn't an undertaking for the faint of heart; those templates hide a lot of ugly transitional code. In fact, I would recommend against modifying the Visual MainWin templates at all; the workarounds you create using .NET code after the templates set things up are sure to work better.
Visual MainWin only supports Visual Studio .NET 2003. Owners of older Visual Studio .NET products are essentially out of luck. You're fine, though, if you're looking towards the future: MainSoft plans to provide complete support for Visual Studio .NET 2005 (Whidbey) when it arrives on the scene. Anything you create now should also work fine with the updated version. The Whidbey version of the product will include some additional features according to
Jeremy Barkan, a developer at MainSoft, including:
Web Parts mapping to Java Specification Request (JSR) 168
ASP.NET 2.0
Generics
Java Development Kit (JDK) 1.5 Support
Web Service-Security (WS-Security) and additional WS standards
Installation
I began testing the product using just the features that it provides natively. This isn't a standard Visual Studio add-on, however, and you need to install a few additional items with it. Be certain to read the VMW4J2EEGettingStarted.pdf file before you begin working with the product or you'll find that things won't work as expected. Make sure you have all of the required Visual Studio .NET functionality installed; many developers don't install Visual J#, but you need it with this product.
Installing Visual MainWin comes next. The VMW4J2EEGettingStarted.pdf file gets right into the installation process and does a good job of telling you how to start the tasks
you need to perform when you have the CD. If you download the product from the Internet site, you'll need to start the setup by double clicking the vmw4j2ee_150.exe file, rather than the Setup.exe file described in the PDF. The setup documents also fail to mention a license file you need to make the product work. Make sure you have the license file before you begin; the vendor sends this file to you in an e-mail message after you download the product. The e-mail also includes instructions for installing the license. Other than these two little differences, the instructions in the PDF work precisely as stated.
The Visual MainWin installation program offers to download and install the Microsoft SQL Java DataBase Connectivity-Open Database Connectivity (JDBC-ODBC) bridge driver. This procedure generally works, but you might want to have a copy of the driver handy just in case. Unfortunately, the setup instructions don't mention this requirement until you're halfway through the installation. A better idea is to get the driver before you begin. Visual MainWin is also supposed to work with other versions of the JDBC-ODBC bridge, such as the one provided with the Sun Java SDK, but the product instructions don't include any information on accomplishing this task.
The proof that the installation succeeded is in Visual Studio .NET. As shown in Figure 1, you should see two new project folders: Visual MainWin VB for J2EE Projects and Visual MainWin C# for J2EE Projects. These projects look very familiar — and that's the point. These projects create Java code, but as far as you're concerned, they could just as easily be .NET applications. Of course, some of the project titles are different. You won't find any Windows form applications in the list, but you'll find the J2EE Class Library template shown in the list.
Figure 1: A successful installation means you have access to the Java templates that Visual MainWin provides.
Visual MainWin is a complex product, so make sure you understand how things work before you use it. For example, I ran into a problem with Tomcat the first few times I used the product. I have IIS set to start automatically when my development machine boots. Unfortunately, this act starts a special Tomcat Web site entry. This site is actually supposed to be stopped; it's a kind of intermediate location for the project files, and it has the same TCP port setting as the Tomcat server. When you start Tomcat, you see quite a few messages scroll by in the console window, and it's very easy to miss the message that says there's a TCP port conflict. However, you won't miss the somewhat unclear message that Tomcat isn't listening when you try to create a project. I usually ended up closing Visual Studio .NET, stopping Tomcat, stopping the IIS Tomcat Web site, restarting Tomcat, and finally reopening Visual Studio .NET to fix the problem.
Starting Simple
Now that you have a fun new tool to try out, it's time to create a project. I decided to try a console application first, but eventually tested all of the templates. In fact, the console application really is a good place to start because it lets you see just how seamlessly Visual MainWin works, without spending a lot of time trying to figure out the Web application support. I used this simple code to test the console application the first time
(additional tests became increasingly complex).
using System;
namespace ConsoleApplication1
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
static void Main(string[] args)
{
Console.WriteLine("Press Enter To Close...");
Console.ReadLine();
}
}
}
Building the application produced three files. The first file is a standard managed executable. The second is a standard JAR file that contains all the Java code. The third is an XML file that contains instructions for running the Java version of the application.
Running the EXE file is like running any application you created in the past. To run the Java application, you need to have Java support installed on the system. The default Visual MainWin installation comes with support in the \Program
Files\Mainsoft\Visual MainWin for J2EE\j2sdk1.4\ folder. To run an application, create a path to the \Program Files\Mainsoft\Visual
MainWin for J2EE\j2sdk1.4\bin\ folder and, at the command prompt, type:
Press Enter, and you'll see the expected output: text telling you to press Enter to close and the application waiting until you press Enter.
The command line isn't too hard to figure out. The Java.EXE file lets you execute command line Java applications. The -classpath switch tells where to find the classes used for this example. The first JAR (a compressed file similar to a ZIP) file contains the code for the sample application. The second JAR contains the Java equivalent of the MSCorLib.DLL file. You must include a JAR for every reference you add to your code. The final entry tells Java.EXE what to execute. You include both the namespace and the
class name. You might think there's an easier way to test a console application, but the current product doesn't provide one when you want to run the application at the command prompt. The RunTarget.bat file located in the \Program Files\Mainsoft\Visual MainWin for J2EE\bin folder appears to provide functionality for
Web applications, not for console applications.