|
This demo shows how JNBridgePro can be used to construct a .NET console
application that calls Java classes. In this example, JNBridgePro is used to
allow .NET code to call log4j, a Java-based logging
package developed as part of the Apache project.
The steps involved include generating the .NET proxies that call the Java
classes, creating .NET code that calls the proxies and, indirectly, the
corresponding Java classes, and setting up and run the code.
Assume an existing Java class, loggerDemo.JavaClass, that includes an instance method
doIt() that sends a log message to log4j.
We 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.
|