Quick Start - Access .NET from Java

Java/J2EE .NET Interoperability Products Page

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

Synopsis

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:

Access .NET from Java

Note: $USER_INSTALL_DIR$ is the directory where J-Integra for .NET has been installed. If this location contains whitespace characters (e.g. C:\Program Files\...), you may need to include it within "" when referencing it at the command-line.

Prerequisites

  1. 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.

  2. A platform with J-Integra for .NET 1.5.1295 (or higher) installed. This will be known throughout the example as the Java platform.

  3. 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.

  4. Verify that GenService is installed correctly on the .NET platform.

Steps to Follow

  1. Run Janetor to install J-Integra® for .NET license

  2. Download the Pre-Generated Batch Files

  3. Run the .NET Server

  4. Compile and Run the Java Client

Run Janetor to install J-Integra® for .NET license

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.

  1. Windows

    Launch Janetor from the Start Menu.

    Command-Line
    java -jar $USER_INSTALL_DIR$\lib\janetor.jar
    
  2. Select File - Open and open janet.xml located in $USER_INSTALL_DIR$\examples\java_csharp\java_client.

  3. Install your J-Integra® for .NET product license. See Installing the J-Integra® for .NET license for further information.

  4. Before you exit Janetor, save the configuration by going to File - Save.

Download the Pre-Generated Batch Files

Download the following files and save them to your $USER_INSTALL_DIR$\examples\java_csharp\ directory:

     a) runClient.bat
     b) startServer.bat

Run the .NET Server

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.

  1. Run the pre-generated batch file to launch the J-Integra for .NET Server:
  2.   $USER_INSTALL_DIR$\examples\java_csharp\startServer.bat

  3. You should see the console output:

      Host is ready to process remote messages.
      Press ENTER to exit
    

Compile and Run the Java Client

Perform this step on the Java platform.

In this final step, you will compile and run the Java client.

  1. Run the pre-generated batch file to recompile the proxies and launch the C# client:
  2.     $USER_INSTALL_DIR$\examples\java_csharp\runClient.bat

  3. 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.

© 2005 Intrinsyc Software Inc. Legal