0

I'm having an issue using the Maven exec plugin to execute the Java tool javah. I am trying to specify the output directory to javah where headers files are to be placed but I get the error:

[INFO] --- exec-maven-plugin:1.5.0:exec (create-jni-headers) @ jni-test-osgi --- Error: unknown option: -d /home/kerry [ERROR] Command execution failed.

This is the relevant section of the POM:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>create-jni-headers</id>
            <goals>
                <goal>exec</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
                <executable>javah</executable>
                <workingDirectory>${project.build.outputDirectory}</workingDirectory>
                <arguments>
                    <argument>-d /home/kerry</argument>
                    <argument>com.javatechnics.jni.test.osgi.HelloWorld</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

If I execute javah -d /home/kerry com.javatechnics.jni.test.osgi.HelloWorld from a command line then there is no problem.

Am I doing something wrong or is there a problem with the Maven exec plugin?

D-Dᴙum
  • 7,689
  • 8
  • 58
  • 97

1 Answers1

0

Each "argument" must have its own line:

<argument>-d</argument>
<argument>/home/kerry</argument>
<argument>com.javatechnics.jni.test.osgi.HelloWorld</argument>

Otherwise it comes through as

javah "-d /home/kerry" com.javatechnics.jni.test.osgi.HelloWorld

where "-d /home/kerry" is a single argument that is unknown to the javah command. Hence the error.

Seelenvirtuose
  • 20,273
  • 6
  • 37
  • 66