In order for Java clients to access .NET objects in a .NET assembly using J-Integra® for .NET, Java proxies must be generated from the assembly. These Java proxies in turn are deployed on the Java platform to be referenced by the clients. The GenJava development tool is a pure Java tool that invokes GenService to obtain details about the assembly, and generate Java proxies from it. This section describes how to generate Java proxy files on an assembly using GenJava.
When reading this section, keep in mind the following important details:
GenJava reads a settings file in order to know what proxies to generate, and where to output the .NET assembly to. By default, this file is called genjava.xml and loaded from the same directory where GenJava is launched. A different filename can be specified (see below).
Unlike GenNet, actual proxy generation is done by GenJava, and not GenService. In the same way however, J-Integra® for .NET supports remote proxy generation. That is, the Java proxies are output to the platform where GenJava resides.
Use this section as a quick reference to start GenJava.
Launch GenJava from the Start Menu.
java -jar $USER_INSTALL_DIR$\lib\genjava.jar [arguments]
Possible arguments include:
-f | -file filename
|Read settings from filename||
-n | -nogui
|Launch GenJava in non-interactive mode (see below).||
The J-Integra® for .NET runtime (janet.jar) must also be in $USER_INSTALL_DIR$\lib. The main class that is called when launching GenJava is com.intrinsyc.janet.genjava.GenJavaApp.
GenJava can be started in interactive, or non-interactive mode.
When GenJava first starts, it uses IP multicast to find existing instances of GenService:
Note: Your screen may look diffent based on installed .NET platforms. If possible, please choose Genservice_20 as it can analyze all framework versions .NET assemblies. For details of the two GenService versions, please refer to the section Multiple Versions: Genservice & GenService 2005 in the GenService section.
Select an instance and click Next>.
If, for whatever reason, multicasting is unavailable on your network, then GenJava will fail to find any instances of GenService that aren't running locally:
If you select Enter Host Manually and click Next>, you will be prompted to manually enter a URI where GenService can be found. You should enter the following URI and click OK:
The next screen prompts for the location of the assembly along with the output directory where the Java proxies will go. The Browse... button for the location of the assembly will be disabled if GenService was found to be remote rather than local to the machine that GenJava was started from.
The final screen shows the output of the generation, and if there were any errors encountered:
Notice the warning message displayed in the screenshot:
**Server ignored: non-public or not MarshalByRefObject/Serializable
GenService will display this message for every .NET class that it encounters that does not inherit from MarshalByRefObject (mandatory for marshal by reference objects as dictated by .NET Remoting) or have the Serializable attribute (mandatory for marshal by value objects). Such classes will be ignored and no Java proxy generated for them.
GenJava is normally used interactively, with a graphical user interface, but it can also be run without stepping through the GUI wizard. This can be useful when GenJava is used as part of an automated build procedure, for example. To use GenJava in this non-interactive mode, GenJava must first be run in interactive mode to create a valid settings file. It can then be run again non-interactively using the same settings.
To create the settings file, simply run through the steps above and once generation has been successful and the Finish is clicked, a settings file will be created and saved to genjava.xml. If GenJava is run from Windows, then genjava.xml will be created in $USER_INSTALL_DIR$, otherwise, it will be created from wherever GenJava was launched on the command-line.
To run in non-interactive mode, GenJava must be started from the command-line. Review Starting GenJava to see how to start GenJava in non-interactive mode.
If the settings file is read and processed correctly, GenJava creates the proxies immediately and exits. All status and error messages are displayed on the console's standard output and standard error streams.