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

  • Cloud-Focused .NET Aspire 9.1 Released

    Along with .NET 10 Preview 1, Microsoft released.NET Aspire 9.1, the latest update to its opinionated, cloud-ready stack for building resilient, observable, and configurable cloud-native applications with .NET.

  • Microsoft Ships First .NET 10 Preview

    Microsoft shipped .NET 10 Preview 1, introducing a raft of improvements and fixes across performance, libraries, and the developer experience.

  • C# Dev Kit Previews .NET Aspire Orchestration

    Microsoft's dev team has been busy updating the C# Dev Kit, a Visual Studio Code extension that enhances the C# development experience by providing tools for managing, debugging, and editing C# projects.

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

Subscribe on YouTube

Upcoming Training Events