Quick Start - Access .NET from Java |
This quick start example demonstrates how easy to access .NET from Java client, using pre-generated batch files. For completed example with all detailed steps, please take a look at Access .NET from Java
Use this example as a guideline to show you how to access a .NET Singleton, Client Activated Objects (CAO) and "marshal-by-value" objects from Java using J-Integra for .NET. This example also demonstrates how a java client can catch a custom exception thrown by a .NET 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 client.
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\java_csharp\java_client.
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\java_csharp\ directory:
a) runClient.bat
b) startServer.bat
Perform this step on the .NET platform.
In this step, you will need to configure and start the .NET server so it can respond to incoming TCP requests.
$USER_INSTALL_DIR$\examples\java_csharp\startServer.bat
Host is ready to process remote messages. Press ENTER to exit
Perform this step on the Java platform.
In this final step, you will compile and run the Java client.
$USER_INSTALL_DIR$\examples\java_csharp\runClient.bat
You should see the following output:
*** Testing singleton *** Hello World from the Factory *** SUCCESS *** *** Testing CAO *** Original CAO: Hello, cbr1 Modified CAO: Hello, cbr1 [modified] Another CAO: Hello, cbr2 Original CAO array: Hello, cbr0 Hello, cbr1 Hello, cbr2 Hello, cbr3 Hello, cbr4 Hello, cbr5 Hello, cbr6 Hello, cbr7 Hello, cbr8 Hello, cbr9 Modified CAO array: Hello, [modified] cbr0 Hello, [modified] cbr1 Hello, [modified] cbr2 Hello, [modified] cbr3 Hello, [modified] cbr4 Hello, [modified] cbr5 Hello, [modified] cbr6 Hello, [modified] cbr7 Hello, [modified] cbr8 Hello, [modified] cbr9 *** SUCCESS *** *** Testing pass by value *** csharp_server.ClassByValue has contents: cbv1, 77, and c *** SUCCESS *** *** Testing custom exception *** *** SUCCESS - caught Custom exception: charp_server sample custom exception
Examine Client.java to look at the various tests that the client runs to access the .NET objects.