【问题标题】:javah fails when executed via Maven exec plugin通过 Maven exec 插件执行 javah 失败
【发布时间】:2017-01-07 03:14:29
【问题描述】:

我在使用 Maven exec 插件执行 Java 工具 javah 时遇到问题。我正在尝试将输出目录指定为 javah 要放置头文件的位置,但出现错误:

[INFO] --- exec-maven-plugin:1.5.0:exec (create-jni-headers) @ jni-test-osgi --- 错误:未知选项:-d /home/kerry [错误] 命令执行失败。

这是 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>

如果我从命令行执行javah -d /home/kerry com.javatechnics.jni.test.osgi.HelloWorld 则没有问题。

是我做错了什么还是 Maven exec 插件有问题?

【问题讨论】:

    标签: java maven exec-maven-plugin


    【解决方案1】:

    每个“参数”必须有自己的一行:

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

    否则它会通过

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

    其中“-d /home/kerry”是javah 命令未知的单个参数。因此出现错误。

    【讨论】:

    • 我以为我已经尝试过了,但显然没有!非常感谢。
    猜你喜欢
    • 2011-12-07
    • 2022-12-03
    • 2012-12-08
    • 1970-01-01
    • 1970-01-01
    • 2015-11-30
    • 2013-05-30
    • 2011-08-10
    • 2021-04-12
    相关资源
    最近更新 更多