The regjvm Tool
jCOM allows languages supporting COM to access Java objects as though they were COM objects.
To do this you need to register (on the COM client machine) a reference to the JVM in which the Java objects run. The regjvm tool enables you to create and manage all the JVM references on a machine:
There is a GUI version of the tool, regjvm, and a command line version, regjvmcmd. The following sections look at:
-
JVM Modes
-
The User Interface
-
DCOM mode options
-
Native mode options
-
Native mode in process options
JVM modes
A JVM may be accessed from COM clients using one of three different modes:
DCOM mode
DCOM mode does not require any native code on the Java server side, which means your Java code may be located on a Unix machine or any machine with a Java Virtual Machine installed. When you register the JVM on the Windows client machine you define the name of the server host machine (it may be localhost for local components) and a port number.
The Java code in the JVM must call com.bea.jcom.Jvm.register("<jvm id>"), where <jvm id> is the id of the JVM as defined in regjvm. The JVM must also be started with the JCOM_DCOM_PORT property set to the port defined in regjvm tool for the specified <jvm id>.
Native mode (out of process)
Native mode currently only works on the local machine. Other than the JVM name no additional parameters are necessary.
The JVM must call com.bea.jcom.Jvm.register("<jvm id>"), where <jvm id> is the id of the JVM as defined in regjvm. The JVM must also be started with the JCOM_NATIVE_MODE property set.
Native mode in process
Using native mode in process allows the user to actually load the Java object into the same process as the COM client. Both objects must of course be located on the same machine.
The JVM need not call com.bea.jcom.Jvm.register() or be started as an extra process to the client.
The User Interface of the regjvm GUI Tool
The displayed dialog is split into two parts.
-
The top part is for selection and management of all JVMs on the current machine. JVMs may be added, altered or deleted. Before switching to a different JVM, changes made to the currently selected JVM must be saved. It is also here that the different JVM modes can be selected which then dictates the information required in the lower half of the window.
-
The lower half of the windows contains the details required for each JVM, according to the mode of the JVM. In addition to the JVM details there is an advanced checkbox which when selected displays advanced options for each JVM mode. The meanings of the options are discussed in the following sections.
DCOM Mode Options for the regjvm GUI Tool
Standard Options
-
Hostname (required) - The IP name or IP address where the JVM is located.
-
Port (required) - The port used to initiate contact with the JVM.
Advanced Options
-
Launch command (optional) - The command to be used if the JVM is to be automatically launched. Typically this would be something like: c:\bea\jdk131\bin\java -classpath c:\bea\wlserver6.1\jcom\lib\jcom.jar; c:\pure MyMainClass.
-
Launch options (optional) - Allows you to specify the initial window state of the server component.
-
Generate Script... (optional) - Allows the user to generate a registry script selecting the settings of the JVM.
Native Mode Options for the regjvm GUI Tool
Standard Options
There are no standard options for this mode.
Advanced Options
-
Launch command (optional) - see DCOM mode.
-
Launch options (optional) - see DCOM mode.
-
Generate Script... (optional) - see DCOM mode.
Native Mode in Process Options for the regjvm GUI Tool
Standard Options
-
JVM (required) - The JVM must be specified. Clicking the browse button allows you to select your own JVM, clicking the Scan button scans your local machine for JVMs (this may take a few minutes) and inserts them in the listbox for your selection.
Advanced Options
-
Classpath (optional) - The CLASSPATH for the JVM - if this is left blank the CLASSPATH environment variable at runtime is used. Otherwise the contents are added to the CLASSPATH environment variable.
-
Main class (optional) - The name of the class containing a Main method which you wish to be called.
-
Properties (optional) - Any properties which you require to be set. Must have the following syntax: prop1=value1 prop2=value2...
-
Java 2 (optional) - When setting properties this must be set when using Java 2 (JDK 1.2.x, 1.3.x) and cleared when using 1.1.x.
-
Generate Script... (optional) - see DCOM mode.
The regjvmcmd Command Line Tool
Run
regjvmcmd
without parameters to get a summary of the parameters.
In its simplest form, you specify
-
a jvm ID (corresponding to the name used in com.bea.jcom.Jvm.register("JvmId")),
-
and the binding that can be used to access the JVM, in the form hostname[port], where hostname is the name of the machine running the JVM, and port is the TCP/IP port specifed when starting the JVM by setting the JCOM_DCOM_PORT property (eg java -DJCOM_DCOM_PORT=1234 MyMainClass).
If you no longer need to have the JVM registered, or if you wish to change its registration, you must first unregister it using regjvmcmd /unregister JvmId