简体   繁体   中英

Open JDK 11 and javah in pom.xml

I switched my java version from java 8 to java 11 , and it seems that in java 11 javah is removed from JDK bin folder, before I was executing the javah command in my pom.xml like below

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

Since javah has been removed from JDK 11 how can I replace the above javah command with javac -h in my pom to work with java 11

The error I get is

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (javac -h) on project myProject: Command execution failed.: Process exited with an error: 2 (Exit value: 2)

Any idea? Thanks

You should modify your execution as :

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

based on the the javac --help

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

Here is another way to generate the sources, this time by adding on to the maven-compiler-plugin :

<compilerArgs>
    <arg>-h</arg>
    <!-- where to put include files (change to whatever) -->
    <arg>${project.basedir}/src/main/c++/include</arg>
    <arg>-d</arg>
    <!-- where to put the generated .class files (probably don't change this) -->
    <arg>${project.build.outputDirectory}</arg>
</compilerArgs>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM