Quick Start - Access Java from .NET

Java/J2EE .NET Interoperability Products Page

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.

Synopsis

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:

Access Java from .NET

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

  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 J-Integra for .NET Server

  4. Compile the Proxies and run the .NET 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\csharp_java.

  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\csharp_java\ directory:

     a) gennet.xml
     b) runClient.bat
     c) startServer.bat

Run the J-Integra® for .NET Server

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

Compile the Proxies and Run the .NET Client

Perform this step on the .NET platform.

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

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

© 2005 Intrinsyc Software Inc. Legal