SDK - How To: Access The TRIM Context SDK via Java

  • KM507212
  • 20-Sep-2008
  • 20-Sep-2008

Archived Content: This information is no longer maintained and is provided "as is" for your convenience.


How To: Access The TRIM Context SDK via Java

Return to General Articles page

Java provides numerous interfaces to other technology platforms, such as Microsoft’s Component Object Model. This article describes using the Java Native Interface (JNI) to bridge to the TRIM Context COM SDK.


The Java Native Interface is designed to allow Java applications to call any platform-limited technology or proprietary environment, such as COM.

While it is possible to construct your own JNI wrappers for the TRIM Context SDK and all of its COM objects, it makes much more sense to use an automated generation tool to do this. There are many, many of these tools available. One of the easiest to use is IBM’s Bridge2Java tool, available for free from the IBM Alphaworks site at

Bridge2Java includes a GUI generator for the JNI wrapper, code samples for popular desktop applications, and brief instructions for use. It does not include comprehensive documentation. Run the ProxyGen utility from Bridge2Java over the TRIM Context SDK DLL, trimsdk.dll, and wrapper classes for all TRIM Context SDK COM objects will be generated in your nominated directory.

Method names

Almost all method and property names will be wrapped with get_ and set_ prefixes to the original COM method and property names. For instance, Database.Id becomes Database.set_Id() and Database.get_Id().

For more detail on the generated class, method and property names, inspect the java class files produced by the ProxyGen utility.


The following sample illustrates using the generated classes to invoke the SDK, create a database object, and return some simple information from the TRIM Context system.

import TRIMSDK.*; 
public class TRIMJavaSample
  public static void main(java.lang.String[] args) {
      Database db;
          // Initialize the Java2Com Environment

          // Create a new TRIM Database object
          db = new Database();

          // Set the database ID to the demo database ID of 45

          // Connect

          // Retrieve current workgroup and echo to stdout
          java.lang.System.out.println( db.get_CurrentWorkgroup() );

          // Disconnect

      catch ( e)
          java.lang.System.out.println( "COM Exception:" );
          java.lang.System.out.println( Long.toHexString((e.getHResult())) );
          java.lang.System.out.println( e.getMessage() );

      catch (Exception e)
          java.lang.System.out.println("message: " + e.getMessage());

          db = null;

Other References

* Oracle Metalink Document ID: Note:47634.1, “Developer - OLE/DDE/VBX/OCX Frequently Asked Questions” (Requires Metalink registration)
* Oracle Whitepaper, "Client Side OLE Integration from Oracle9i Forms"