Developer Product Briefs

Use Java Classes in .NET Apps

NBridgePro helps developers bridge the gap.

Many companies have both Java and .NET developers on code projects, but there’s often a significant communication gap between the two camps.

JNBridgePro helps developers bridge that gap. It generates wrappers (or proxies) for Java binaries, so you can call Java classes (running on a Java Virtual Machine) from your .NET code. (The product also generates code to call .NET classes from Java, but that’s not reviewed here.) The platform intercommunication can be through shared memory on the same server, binary transfer (remoting) over TCP, or SOAP. I chose shared memory as the fastest option, while recognizing it isn’t always practical to run two platforms on one machine.

My previous experiences with Java have been mixed, but limited, so I was curious how well this tool could help analyze and take advantage of the functionality of Java projects. The short answer: It helps a lot, and even .NET developers with a severe case of Javaphobia can probably benefit significantly from its functionality.

Setting up proved uneventful, but I should note that the product itself doesn’t ship with a Java runtime. The instructions for the brand-new Visual Studio plug-in also assume knowledge of the older JNBridge standalone utility. In turn, the standalone’s instructions assume you’re familiar with Java-specific terminology. For example, it’s critical to configure various “classpath” values for JAR files.

Figure 1
[Click on image for larger view.]
Build a Bridge to Java Classes. JNBridgePro 4.0 offers Visual Studio 2008 integration so you can generate wrappers for Java classes within the Microsoft IDE. As a .NET developer, it can be hard to figure out the Java dependencies when selecting classes.

With a basic knowledge of the standalone utility, the VS 2008 plug-in made more sense. Installing the product adds a JNBridge project type, DotNetToJavaProxies template, and a JNBridgePro menu to the VS IDE. When you open the generated DotNetToJavaProxies.jnb file, you see a list of eligible Java classes in the Environment column. You click on Add and use the checkboxes to select the Java properties and methods that you want to expose to .NET. This is another area where it helps to know Java and the specific classes you intend to use.

Less than three hours after cracking open the software, I was able to build and reference the required assemblies and run the sample .NET console executable. JNBridge uses a Java class to produce logging info. My exploration to convert the logging sample to a Web application using ASP.NET worked, but it would have been easier with a little more handholding.

For VS 2008 users, I’d like to see the vendor rewrite the Getting Started guide to avoid side-trips to separate manuals, include numbered steps in the procedures, and define Java terms.

JNBridge licenses its products per desktop, per server, and per developer. As such, hooking up an ASP.NET application to Java-based business logic on the back-end would start at $1,390 for the Web server plus $995 for one developer using the Standard Edition. The project I converted worked well, and it hinted at the much larger potential possible for a product like this in enterprise shops. JNBridge’s suitability in that role is beyond the scope of this review, but look for a follow-up review in a future issue of VSM that addresses that particular issue.

At A Glance JNBridgePro 4.0
JNBridge LLC
Web:
www.jnbridge.com
Phone: 877-584-6082
Price: $995 per developer, $1,395 per server, $95 per desktop deployment
Quick Facts: Bridges Java classes and .NET assemblies to allow one to call methods and use properties from the other.
Pros: Offers a quick solution to the Java/.NET divide; uses shared memory, remoting, or SOAP; good integration with Visual Studio environment.
Cons: Documentation needs organization and assumes an understanding of Java; no royalty-free runtimes.

About the Author

Ken Cox is a Canadian .NET programming writer and the author of "ASP.NET 3.5 for Dummies" (Wiley).

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube