The Regjvm Tool

Contents

  • Introduction
  • DCOM Mode
  • Native Mode
  • Native Mode In-Process
  • Command Line Mode (Regjvmcmd)
  • Increasing the JVM Memory
  • Registry Settings


    Introduction

    J-Integra® allows COM programming languages (such as VB and C++) to access Java objects as though they were COM objects. In order to do this you need to run regjvm.exe on the COM client machine to register a reference to the JVM in which the Java objects run. The regjvm tool allows you to create and manage multiple JVM references.

    1. The top part is for the selection and management of all JVMs on the current machine. JVMs may be added, modified, or deleted. Before switching to a different JVM, changes made to the currently selected JVM must be saved. You can also select which mode you want each JVM to run in.

    2. The lower half of the windows contains the details required for each JVM according to the mode it is set to run in. In addition to the JVM details there is an advanced checkbox which, when selected, displays advanced options for each mode.


    DCOM Mode

    DCOM mode does not require any native code on the Java server side, which means your Java code may be located on any platform that has a JVM installed (e.g. Unix).

    When you register the JVM on the Windows client machine, you define the name of the server host machine (which may be localhost for local components) and a port number.

    The Java code running in the JVM must call com.linar.jintegra.Jvm.register("<jvm id>"), where <jvm id> is the JVM name entered using regjvm. The JVM must be started with the JINTEGRA_DCOM_PORT property set to the port defined using regjvm.

    Standard Options

    1. Hostname (required) - The IP name or IP address where the JVM is located.

    2. Port (required) - The port used to initiate contact with the JVM.

    Advanced Options

    1. Launch command (optional) - The command to be used if the JVM is to be automatically launched on local machine. Typically this would be something like:

        d:\jdk1.3.1\bin\java.exe -DJINTEGRA_DCOM_PORT=1350 -classpath C:\jintegra\lib\jintegra.jar;d:\pure MyMainClass

      Alternatively, if the classpath is too long, you can also specify a batch file instead:

        C:\JIntegraWorks\MyTest\runDCOM.bat

      * A JVM on the local machine can be automatically launched using early or late binding, but not using a "zero client" installation.

    2. Launch options (optional) - Allows you to specify the initial window state of the server component.

    3. Generate Script... (optional) - Allows the user to generate a registry script reflecting the settings of the JVM.


    Native Mode

    Native mode only works when both the COM client and JVM must be running on the same machine.

    Other than the JVM name, no additional parameters are necessary. The JVM must call com.linar.jintegra.Jvm.register("<jvm id>"), where <jvm id> is the JVM name entered using regjvm.

    The JVM must be started with the JINTEGRA_NATIVE_MODE property set. The JINTEGRA_DCOM_PORT property is not required in this mode.

    Advanced Options

    1. Launch command (optional) - The command to be used if the JVM is to be automatically launched on local machine. Typically this would be something like:

        d:\jdk1.3.1\bin\java.exe -DJINTEGRA_NATIVE_MODE -classpath C:\jintegra\lib\jintegra.jar;d:\pure MyMainClass

      Alternatively, if the classpath is too long, you can also specify a batch file instead:

        C:\JIntegraWorks\MyTest\runNative.bat

      * A JVM on the local machine can be automatically launched using early or late binding, but not using a "zero client" installation.

    2. Launch options (optional) - Allows you to specify the initial window state of the server component.

    3. Generate Script... (optional) - Allows the user to generate a registry script reflecting the settings of the JVM.


    Native Mode In-Process

    Using native mode in-process allows the user to actually load the JVM into the same process as the COM client. Both the COM client and JVM must be running on the same machine.

    The JVM does not need to invoke com.linar.jintegra.Jvm.register() or be started separately from the client.

    Standard Options

    1. JVM (required) - The JVM must be specified. Clicking Browse allows you to select your own JVM. Clicking Scan searches your local machine for exposed JVMs (this may take a few minutes) and inserts them in the listbox for selection.

    Advanced Options

    1. Classpath (required) - This value is used as the CLASSPATH for the in-process JVM. The CLASSPAH value must include:
      • The jintegra.jar file.
      • The directory containing the II*.java files generated by java2com (if using early binding).
      • The directory containing the Java classes that will be accessed by the COM client.

    2. Main class (optional) - The name of the class containing the main() method that should be called when the JVM starts up.

    3. Properties (optional) - Java properties that are required at runtime.

    4. Generate Script... (optional) - Allows the user to generate a registry script reflecting the settings of the JVM.


    Command Line Mode (Regjvmcmd)

    The regjvmcmd tool is a non-GUI version of regjvm. Type regjvmcmd /? to see its usage. Example usage includes...


    Increasing the JVM Memory

    If your application requires a large amount of memory, you should increase the max heap size of the JVM (-Xmx option). For example...

    You may also need to use the -Xms and -Xss options. Run java -X to see the descriptions of these options. SUN's JVM process (java.exe) has a 1MB stack size by default. Under certain conditions you may need to increase its stack size. For more information, please take a look at the KB article Stack Overflow with ActiveX Controls.

    To confirm whether or not more memory has been allocated, use the following sample code (example uses JDK 1.4).

    VB

    Private Sub Command1_Click()
      Dim memory As Object
      Set memory = GetObject("ajvm:Memory")
      MsgBox memory.checkMemory
    End Sub

    Java

    public class Memory {
      public static String checkMemory() {
        long memoryBytes = Runtime.getRuntime().maxMemory();
        long memoryMB = memoryBytes/1024/1024;
        long memoryDiff = memoryMB - 64;
        String s = "Runtime.maxMemory: " + memoryMB + "MB\n";
        s = s + "Difference: " + memoryDiff + "MB";
        return s;
      }
    }


    Registry Settings

    If you would like to know which registry settings are modified by regjvm, click the Generate Script button to generate a .reg file, and then open the .reg file using a text editor.