Quick Start - Access Java from .NET |
This quick start example demonstrates how easy to access Java from .NET client, using pre-generated batch files. For completed example with all detailed steps, please take a look at Access Java from .NET.
Use this example as a guideline to show you how to access various Java objects exposed as a .NET Singleton, Client Activated Object (CAO) and "marshal-by-value" object using J-Integra for .NET. This example also demonstrates how a .NET client can catch a custom exception thrown by a java server.
Refer to the diagram below for an overview of the scenario:
A platform with Microsoft Visual Studio .NET 2003 (7.1.3088 or higher) installed, or at least the .NET Framework 1.0.3705 or higher. This will be known throughout the example as the .NET platform.
A platform with J-Integra for .NET 1.5.1295 (or higher) installed. This will be known throughout the example as the Java platform.
A version of JDK (1.3.1 or higher) installed on the Java platform, and the bin directory included in the path. This required to compile and run the Java server.
Verify that GenService is installed correctly on the .NET platform.
Perform this step on the Java platform.
In this step, you will need to install J-Integra® for .NET license for this quick start example. This is done through the Janetor tool.
Launch Janetor from the Start Menu.
java -jar $USER_INSTALL_DIR$\lib\janetor.jar
Select File - Open and open janet.xml located in $USER_INSTALL_DIR$\examples\csharp_java.
Install your J-Integra® for .NET product license. See Installing the J-Integra® for .NET license for further information.
Before you exit Janetor, save the configuration by going to File - Save.
Download the following files and save them to your $USER_INSTALL_DIR$\examples\csharp_java\ directory:
a) gennet.xml
b) runClient.bat
c) startServer.bat
Perform this step on the Java platform.
Run the pre-generated batch file to launch the J-Integra for .NET Server:
$USER_INSTALL_DIR$\examples\csharp_java\startServer.bat
Perform this step on the .NET platform.
$USER_INSTALL_DIR$\examples\csharp_java\runClient.bat
A console should come up and you should see the output:
Hello World! From Singleton Hello World! From Marshal-By-Ref 1 Hello World! From Marshal-By-Val 1 Successfully caught custom exception: java_server sample custom exception Press any key to continue...
Press Enter to exit.