Subclassing is Easy

To subclass the LINCEnvironment object, perform the following:

  1. Create your own Java class as shown in the following example:.

    Remember that the file name must match the class name you choose. In its simplest form, the class looks as follows:

    file com\unisys\jellybeans\MyCEObject.java

    Like the generated components, you must preserve the full path name from 'com' down.

    package com.unisys.jellybeans;
    class MyCEObject extends LINCEnvironment
    { }
  2. The above class can be compiled using the Java compiler you have already downloaded, to create a com\unisys\jellybeans\MyCEObject.class file.

    Note that this file is less than 1k.

    You can create a batch file, with details such as the location of your compiler, to do the compile for you. The following is an example of a batch file named compile.bat:

    rem compile a simple Java class
    rem
    rem remember to adjust to your environment.
    
    rem set the CLASSPATH if not already setup on this machine
    set CLASSPATH = c:\alinc\lib\LINCApplet.jar
    
    rem set the path to the compiler, unless it is already in the path
    set path = %path%;c:\Program files\Microsoft SDK for Java version 3.2\binsd
    
    rem compile the class
    jvc MyCEObject.java
  3. Ensure the class is in a location to which your CLASSPATH statement points. Under the same directory as your generated .class files is a good location. Remember to keep the path intact.

  4. You can now register your class as a COM object. For example, from a command prompt (DOS box), type:

    javareg /register /class:com.unisys.jellybeans.MyCEObject /progid:MyCEObject.Java.1

    The progid can be anything you want, although by convention it is an identifier, the type, and a version number.

  5. In your clients you can now create an instance of your class, rather than the base class. For example,

    Server.CreateObject("MyCEObject.Java.1")

    where MyCEObject is the progid you specified when you registered it with javareg.exe.

You can now use your object as if it was the LINCEnvironment object. It has all of the same properties and methods.