This is a showcase review for our sponsors at The Code Project. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.
Introduction
Figure 1: Use your Visual Studio skills to create applications for Linux.
Your company may have just merged with another company that is a Java shop or your company may want to run your wildly popular ASP.NET 2.0 application across the enterprise, and the enterprise happens to run on Java Enterprise Edition (EE). In fact, you might simply be curious about Linux as a platform. What are your options? You might decide that you want to learn Java and the JSF framework, or PHP, or Ruby and gear up to rewrite your existing applications.
A compelling alternative is to extend your code and skills to Linux and other Java-enabled platforms using Grasshopper 2.0 and the Visual Studio development environment. With Grasshopper, you can keep working with Visual Studio, your preferred IDE, and maintain your high development productivity. In fact, developing for Linux is very much the same as developing for Windows from a Visual Studio perspective. Yes, there are a few small minor differences, but none of them involves skills that you haven't already used. For example, when creating a Java application using Grasshopper, you actually use one of four project templates found in the Visual C# for Java EE or Visual Basic for JavaEE project types: Class Library, ASP.NET Web Service, ASP.NET Web Application, or Console Application. These projects work very much like their .NET counterparts, so all you'll really do is pick up the right project type. Instead of using the built-in Web server, your applications will rely on the Tomcat server supplied as part of Grasshopper, but you still click Debug when you want to test your application. Isn't it nice to know that you can build an application that runs under Linux anytime you want? You can create a test application such as the one shown in Figure 1 using the Visual Studio IDE and run it on SUSE Linux in 10 minutes!
Figure 2. Deployment of your application is easy using Grasshopper.
It really is quite easy
You test your application with Grasshopper locally using the local copy of Tomcat that Mainsoft provides with the Grasshopper installation. After you perform this local test, you set the properties for your project to produce a Web Application Archive (WAR) file (it's on the Java tab that Grasshopper adds to Visual Studio for you, shown in Figure 2) and select the Build command as you normally would to create the application package. You'll end up with an application that is fully compliant to the Java platform specifications and can be used as a self-content deployment package on any Java-capable server.
At this point, you can give your WAR file to the administrator who uses the Tomcat Web Admin console (also known as the Manager) to deploy the WAR file. The application is now available for everyone to use from the Linux server. It's that easy. Notice that you haven't changed any of your ASP.NET coding practices. You code the same way that you always have and let Grasshopper worry about the details.
What you can do with Grasshopper
Here are some more interesting facts and features that make it easy to create new Java EE applications or run your existing ASP.NET applications on Java servers using the Visual Studio IDE and Grasshopper.
Leverage all of the ASP.NET 2.0 productivity features
Grasshopper 2.0 includes all of the functionality required to use ASP.NET 2.0 features in your application. This new ASP.NET version means that you can now create Web applications that rely on the time-saving features of Master Pages, themes and skins, site navigation, login controls, databound controls, and ASP.NET 2.0 security and personalization (through the Grasshopper pure Java membership, role, and profile providers, which require no set-up effort on your part). You can also use all the new ASP.NET 2.0 controls, with the exception of WebParts.
In addition to the ASP.NET 2.0 features, you'll also find that Grasshopper now provides full support for the new C# 2.0 language features, including partial classes, iterators, yield, nullable types, anonymous methods, and generics. These features make your programming experience better by reducing complexity and making code reuse significantly easier. For example, because you have access to generics, you define a class once for any supported data type instead of handling the data types by using overrides. Using generics not only reduces coding time; it also reduces errors because the class gains strong data typing support.
Secure your application with role-based security
Creating a secure application is of critical importance in today's hacker-filled computing environment. Fortunately, Grasshopper brings the out-of-the-box ASP.NET 2.0 authentication and role-based security to the Java runtime. Without any special coding effort, you can use the default Grasshopper membership and roles providers, based on open source Apache Derby [link to: http://db.apache.org/derby], a pure Java embedded database promoted by IBM. Grasshopper does all of the work required to enforce the security you describe in your ASP.NET 2.0 application in the Java EE runtime environment
Figure 3. Create the kind of application you need to make migration easy.
Rely on all of the project support you've come to expect
Grasshopper provides a number of project templates you can use to move your application to Linux as shown in Figure 3. Notice that you can build a class library, Web application, Web service, or console application. All of these application types provide the kind of support you need to create enterprise-level applications that bridge the gap between the resources that you have and those of another organization.
Figure 4: Now you can access any Java code you want from your application.
Leverage Java libraries in your C# or VB project
Grasshopper provides more than a one-way transfer of application code from Visual Studio to the Java platform. Most mergers involve getting two different applications to work together so that the enterprise can work with all of the data of the two previous companies. In many cases, you'll find that you need to work with existing Java class libraries.
You do need to use a slightly different process to interact with Java resources than you would with local Windows resources. Right-click the Reference folder in the Solution Explorer and choose Add Java Reference from the context menu. Grasshopper adds this entry for you. You'll see an Add Java Reference dialog box like the one shown in Figure 4. No matter where the Java code you need to use resides, you can add it to your application. In fact, you can use this technique to add common Java libraries, such as log4J or Lucene, to a test application.
Debug your applications as normal
Debugging your application might be a concern because the assumption is that the Java equivalent won't use the standard Visual Studio debugger. Fortunately, Grasshopper also makes debugging seamless. You press F5 as you always do to start the application. The Visual Studio IDE relies on the same user interface for setting breakpoints and viewing variable data as normal. In fact, you won't see any differences at all when debugging. You can even debug your Java code when you have the required source code. Of special importance is that you can also debug your .NET application once deployed in your Java server, by attaching the Visual Studio debugger interface to your remote Tomcat server VM. So, you can perform debugging on the server where the bug occurs and not just in the development environment.
Work with common databases
An organization is defined by the data it possesses. In fact, the data that your systems store and manage is worth far more than anything else in the system. Consequently, developers have good reason to worry about database support for ASP.NET applications. Grasshopper provides full support for the System.Data classes. You can easily work with Microsoft SQL Server, Oracle, IBM DB2, Sybase, Derby, PostgreSQL, or MySQL. Remember that you can use any Java library with Grasshopper, which means that if you don't find a particular database mentioned in this list, you can always access it using the required Java library.
Grasshopper ADO.NET can run on any Java Database Connectivity (JDBC) capable database. JDBC is the Java alternative to Open Database Connectivity (ODBC) in Windows. If a database has a JDBC driver, you can access it using Grasshopper ADO.NET APIs. All you need is the driver class property in the connection string as explained in the product documentation. The Sun Web site provides JDBC drivers for a significant number of databases including: SQL Server, Oracle, DB2, Cloudscape, PostgreSQL, and any JDBC capable database.
It's interesting to note that JDBC actually provides more freely downloadable drivers than ODBC does, and this simple difference may provide a good reason for you to rely on JDBC, rather than ODBC for your database needs! You might even want to use Grasshopper if for no other reason than ensuring you can access every possible database without having to worry about drivers!
Perform tasks at the command line
Many developers prefer to work at the command line than rely on the IDE to perform tasks for them. The need to work at the command line is especially important for nightly unattended builds. Grasshopper lets you work your way by supporting the MSBuild utility. All you need to do is add the .NET Framework to your PATH environment variable and create a VMW_HOME environment variable to point to the Grasshopper folder on your system. In fact, Grasshopper supplies a command prompt that sets these values that you can find in the Grasshopper Version 2.0 program group.
How does Grasshopper work?
By now, you're wondering how Grasshopper does all of the things that it does. It may seem like magic, but Mainsoft has actually based it on very solid computer science. The Grasshopper cross-compiler takes the Intermediate Language (IL) file that the Visual Studio compiler produces and turns it into Java bytecode. Instead of executing the code using the Common Language Runtime (CLR) as normal, you can now execute it using the Java Virtual Machine (JVM) on a Linux machine.
Of course, your application IL file doesn't contain everything needed to run it. If you look in the \WINDOWS\assembly folder on your system, you'll see a host of assemblies that .NET relies on to make your application work. Grasshopper provides Java bytecode equivalents of the assemblies relevant for server side applications so that your application finds what it needs while running under Linux. As far as your application is concerned, nothing has changed � it's using the same resources it normally would.
It's important to note that Grasshopper performs all of its so-called magic using standardized techniques. Mainsoft is part of the Visual Studio Industry Partner (VSIP) program, which ensures the cross-platform technologies meet the highest requirements for an add-on. All of the add-on features meet ECMA standard 335. The C# portions of Grasshopper meet the ECMA standard 334 requirements. All of the Java bytecode that Grasshopper generates meets the Java Virtual Machine (JVM) specifications.
Conclusion
As you can see, Grasshopper is a standards-based product that is easy to use and makes converting your .NET project on Linux and other Java-enabled platforms significantly less complex. See how Grasshopper works for you by downloading the software. Make sure you obtain the free activation key before you begin the installation. All you need to do is register and get hopping!