【问题标题】:Open JDK 11 and javah in pom.xml在 pom.xml 中打开 JDK 11 和 javah
【发布时间】:2019-05-29 22:12:33
【问题描述】:

我将我的 java 版本从 java 8 切换到 java 11 ,似乎在 java 11 中 javah 已从 JDK bin 文件夹中删除,然后我在 pom.xml 中执行 javah 命令,如下所示

<execution>
      <id>javah</id>
      <goals>
         <goal>exec</goal>
      </goals>
      <phase>compile</phase>
      <configuration>
          <executable>javah</executable>
              <arguments>
                  <argument>-classpath</argument>
                  <argument>${project.build.outputDirectory}</argument>
                  <argument>-d</argument>
                  <argument>${build.path}/include</argument>
               </arguments>
      </configuration>
 </execution>

由于 javah 已从 JDK 11 中删除,如何在我的 pom 中将上述 javah 命令替换为 javac -h 以使用 java 11

我得到的错误是

未能在项目 myProject 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (javac -h):命令执行失败。:进程退出并出现错误:2(退出值:2 )

有什么想法吗? 谢谢

【问题讨论】:

  • 您能否与javac -h 分享对您不起作用的内容以及您是如何配置它的?
  • 见上面的编辑
  • 从 JDK 8 开始,建议一直使用 javac -h 而不是 javahjavah 工具已通过 JEP 313 在 JDK 10 中删除。

标签: java maven pom.xml java-11


【解决方案1】:

您应该将执行修改为:

<execution>
    <id>javach</id>
    <goals>
        <goal>exec</goal>
    </goals>
    <phase>compile</phase>
    <configuration>
        <executable>javac</executable>
        <arguments>
            <argument>-classpath</argument>
            <argument>${project.build.outputDirectory}</argument>
            <argument>-h</argument>
            <argument>${build.path}/include</argument>
        </arguments>
    </configuration>
</execution>

基于javac --help

  -h <directory>
        Specify where to place generated native header files

【讨论】:

  • 我收到此错误 [错误] 无法在项目 myProject 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (javac -h):命令执行失败。:进程退出并出现错误:1(退出值:1)-> [Help 1]
  • @wearybands 你可以使用mvn verify -X 执行并分享详细的命令,例如[DEBUG] Executing command line: [javac, -classpath, .../target/classes, -h, .../include],旁边将列出错误的确切原因。
  • 请给我几分钟时间
  • 1. 没有源文件是原因。 2. 确保路径myProject 存在 3. 你不觉得路径C:\sb\build/include 很奇怪吗?
  • @wearybands 参数的值仍然与我观察到的不正确。 -h 需要您要生成本机头文件的目录...-d 需要放置生成的类文件的目录,即您的.class 文件对应的.class 文件..
猜你喜欢
  • 2021-09-23
  • 2019-05-01
  • 2020-03-12
  • 1970-01-01
  • 2019-11-13
  • 1970-01-01
  • 2019-03-03
相关资源
最近更新 更多