EZ Jcom
Java to COM/ActiveX Bridge

Accessing COM objects remotely

EZ JCom can be used to access COM objects remotely, from any other Java platform. The other platform can be another Windows computer, or it can be any other computer that supports Java, for instace, Linux, Unix, Mac, Handhelds, or PDAs.

When EZ JCom is being used to access COM objects remotely, it will be referenced in this documentation as running in remote mode. Otherwise, it will be referenced as running in native mode.

The recommend method of developing remote mode EZ JCom applications is to develop them first in native mode. Once the application is running satisfactorily in native mode, it can then be moved and tested in remote mode. For this, the following changes are required:

The EZ JCom Wizard

(Re) Run the Wizard, and on the page for additional features, click "Remote Access Support...", then select the option to "Build Remote Access files." This will generate files in a subdirectory named ezjRemoteClient. There will also be "MakeJava.bat" and "MakeJar.bat" files in this subdirectory, to make the class files and the jar file.

On the local computer

On the computer where the COM object resides, you must start the EZ JCom server. This can be done by executing the program EzjService.exe from the C:\EZJcom folder (where you installed EZ JCom,) and clicking the button Install EZ JCom Server as a Windows Service.

Make sure the server has the following items available:

  • The ezjcom18.jar file must be in the server's classpath.
  • The class files for the COM object must be in the server's classpath. (These are the original class files from compiling the java files that EZ JCom creates on behalf of the COM object.)
  • The JNI DLL for the COM object should be in the C:\WINDOWS folder or the C:\WINDOWS\system32 folder.
Note: The server's classpath is the "SYSTEM" classpath, and not the "USER" classpath. If you change the SYSTEM classpath, you will need to stop and start the server in order for it to be able to see the changed classpath. Click for explanation of SYSTEM vs USER classpath.

An alternate way to place things in the server classpath is by clicking the "View/Modify EZ JCom Server Configuration", and then by specifying the "Additional Classpath".

On the remote computer

  • The file ezjcom18.jar which is placed in the classpath in native mode, needs to be replaced by the file ezjcomRemoteClient18.jar in the classpath.
  • When you ran EZ JCom on the COM objects, it generated a number of Java files that provided an API for your application. All of these are native mode files. But in the sub-directory (folder) called "ezjcomRemoteClient", EZ JCom has generated the corresponding remote mode files. Compile the files in "ezjcomRemoteClient", and use these on the remote machine. For convenience, a jar file may be used for placement on the remote machine(s).
  • When you run the application on the remote machine, you must provide it the name or IP address of the EZ JCom server. There are a few different ways of doing this, but a simple way is by specifying it on the Java command line. For instance, if your normal command line to start your application is

    java -classpath myfile.jar;comobj.jar;ezjcom18.jar MyProgram

    you would need to modify it to

    java -Dezjcom.hostname=thehost -classpath myfile.jar;remoteComobj.jar;ezjcomRemoteClient18.jar MyProgram

    The definition for "ezjcom.hostname" tells EZ JCom to look for a EZ JCom server running on "thehost".

Server Topics: