在pom.xml中打开JDK 11和javah

wea*_*nds 6 java pom.xml maven java-11

我将Java版本从Java 8切换到Java 11,似乎在Java 11中从JDK bin文件夹中删除了Javah,然后才在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>
Run Code Online (Sandbox Code Playgroud)

由于Javah已从JDK 11中删除,如何在pom中将上述javah命令替换为javac -h以与Java 11一起使用

我得到的错误是

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

任何的想法?谢谢

Nam*_*man 5

您应该将执行修改为:

<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>
Run Code Online (Sandbox Code Playgroud)

基于 javac --help

  -h <directory>
        Specify where to place generated native header files
Run Code Online (Sandbox Code Playgroud)