JNBridgePro: Java and .NET interoperability bridge. JNBridge: Java .NET interoperability

Calling Java from .NET:  Introduction

Suppose you're already using log4j, the Apache logging services package, to log Java events, and you need to integrate .NET classes, with logging messages from both Java and .NET going to the same output. This demo shows how you can use JNBridgePro to construct a .NET console application that calls Java classes, using .NET code to call log4j.

The steps include: (2) start the proxy generator to (5) load the classes, (7) choose and (8) generate the .NET proxies that call the Java classes, (9) create the .NET code that calls the proxies, and (11) run the code.

Let's assume an existing Java class, loggerDemo.JavaClass, that includes an instance method doIt() that sends a log message to log4j. We'll create a .NET-based class, com.jnbridge.demos.logging.DotNetClass that includes its own instance method f() that also sends a log message to log4j. A .NET-based driver method calls both JavaClass and DotNetClass, and we will see how both Java- and .NET-originated logging messages are displayed on the same console output.

Find out more...