com4j:gen

Full name:

org.jvnet.com4j:maven-com4j-plugin:2.1:gen

Description:

Maven2 mojo for running the com4j process to produce .java files for the Java-COM bridge. No required parameters are mentioned below, but you must specify EITHER "libId" or "file" as documented below. Effectively, this is what runs to generate .java code for something like iTunes:
java -jar tlbimp.jar -o generated -p com.mycompany.com4j.itunes "C:\Program Files\iTunes\iTunes.exe"
But we're using it from a Maven2 pom.xml file instead! This allows us to automate code generation without worrying about how com4j is setup.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: runtime.
  • Binds by default to the lifecycle phase: generate-sources.

Optional Parameters

Name Type Since Description
_package String - Specify the desired Java package for generated code. This can be used as the alias, without the leading underscore:
<package>com.mycompany.com4j.someprogram</package>
Or as:
<_package>com.mycompany.com4j.someprogram</_package>
The underscore is there because of the way Maven Mojos are created (the pom.xml tag is the variable name), and "package" is a reserved java word and can't be used as a variable.
Default value is: org.jvnet.com4j.generated.
file File - You must specify either <file> or <libId>. If both are configuration parameters are specified, <libId> will win, and <file> will be ignored.
File is the Win32 program that com4j is generating the COM interface for. This file must exist at the given path. The path can be absolute or relative. Generally this will specify your .exe, .dll, or whatever file has a Windows COM interface.
<file>C:\Program Files\iTunes\iTunes.exe</file>
libId String - You must specify either <file> or <libId>. If both are configuration parameters are specified, <libId> will win, and <file> will be ignored.
LIBID is the Windows identifier of the type library to be processed. It should be a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
Often, the location of type libraries vary from a system to system. For example, the type library for Microsoft Office is installed in the same directory where the user installed Microsoft Office. Because people install things in different places, when multiple people are working on the same project, this makes it difficult to consistently refer to the same type library. libid and libver are useful in this case. Each type library has a unique GUID called "LIBID", and the version of the type library.
For example, Microsoft Excel 2000 type library has the LIBID of:
<libId>00020813-0000-0000-C000-000000000046</libId>
and the version of:
<libVer>1.3</libVer>
Together they allow you to reference a type library without knowing its actual location of the file on the disk.
libVer String - Optional library version. Leave empty to designate the latest package based on the libId. This parameter has no effect if <libId> is not used.
outputDirectory File - Directory in which to create the Java COM wrapper files. This directory will be added to the Maven project's compile source directory list and will therfore be auto-compiled when the Maven compile phase is run.
Default value is: ${project.build.directory}/generated-sources/com4j/java.

Parameter Details

_package:

Specify the desired Java package for generated code. This can be used as the alias, without the leading underscore:
<package>com.mycompany.com4j.someprogram</package>
Or as:
<_package>com.mycompany.com4j.someprogram</_package>
The underscore is there because of the way Maven Mojos are created (the pom.xml tag is the variable name), and "package" is a reserved java word and can't be used as a variable.
  • Type: java.lang.String
  • Required: No
  • Expression: ${package}
  • Default: org.jvnet.com4j.generated

file:

You must specify either <file> or <libId>. If both are configuration parameters are specified, <libId> will win, and <file> will be ignored.
File is the Win32 program that com4j is generating the COM interface for. This file must exist at the given path. The path can be absolute or relative. Generally this will specify your .exe, .dll, or whatever file has a Windows COM interface.
<file>C:\Program Files\iTunes\iTunes.exe</file>
  • Type: java.io.File
  • Required: No
  • Expression: ${file}

libId:

You must specify either <file> or <libId>. If both are configuration parameters are specified, <libId> will win, and <file> will be ignored.
LIBID is the Windows identifier of the type library to be processed. It should be a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
Often, the location of type libraries vary from a system to system. For example, the type library for Microsoft Office is installed in the same directory where the user installed Microsoft Office. Because people install things in different places, when multiple people are working on the same project, this makes it difficult to consistently refer to the same type library. libid and libver are useful in this case. Each type library has a unique GUID called "LIBID", and the version of the type library.
For example, Microsoft Excel 2000 type library has the LIBID of:
<libId>00020813-0000-0000-C000-000000000046</libId>
and the version of:
<libVer>1.3</libVer>
Together they allow you to reference a type library without knowing its actual location of the file on the disk.
  • Type: java.lang.String
  • Required: No
  • Expression: ${libId}

libVer:

Optional library version. Leave empty to designate the latest package based on the libId. This parameter has no effect if <libId> is not used.
  • Type: java.lang.String
  • Required: No
  • Expression: ${libVer}

outputDirectory:

Directory in which to create the Java COM wrapper files. This directory will be added to the Maven project's compile source directory list and will therfore be auto-compiled when the Maven compile phase is run.
  • Type: java.io.File
  • Required: No
  • Expression: ${outputDirectory}
  • Default: ${project.build.directory}/generated-sources/com4j/java