How can I pass -h argument to maven compiler plugin to create JNI header files











up vote
1
down vote

favorite












I already tried passing this argument in the pom but it does not recognize it. Since jdk 8 we dont have to manually run javah to generate header files rather we can pass -h argument to javac and generate the header files when compiling. So if I can pass "-h dir" to maven compiler plugin I can generate the header files when I run mvn compile



<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-verbose</arg>
<arg>-h .</arg>
</compilerArgs>
</configuration>
</plugin>


But when I run mvn install I get this



[INFO] BUILD FAILURE



[INFO] ------------------------------------------------------------------------



[INFO] Total time: 2.936 s



[INFO] Finished at: 2018-11-07T14:52:49+05:30



[INFO] Final Memory: 9M/155M



[INFO]------------------------------------------------------------------------



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project adiesha-native: Fatal error compiling: invalid flag: -h . -> [Help 1]



Is there any other way to do this with maven or do i have to manually create them using "javac -h dir"



Any help would be greatly appreciated










share|improve this question




















  • 1




    try <arg>-h</arg> <arg>.</arg> (two args). And please dont post links to screenshots on SO, rather paste the real code in the question (most people will not bother to click on external links)
    – Gyro Gearless
    Nov 7 at 9:13










  • @GyroGearless Thanks It worked. I will edit the post. (Thanks for the advice)
    – Adiesha
    Nov 7 at 9:20










  • I would rather run javac -h manually. Having the automagically synchronized headers is, most likely, not enough. If something changes in the interface, you will need to adjust the C++ implementations, too. It may be nice to verify that the autogenerated headers are not changed, but this involves a separate custom build step to run diff against the current git copy of same header files.
    – Alex Cohn
    Nov 7 at 12:37










  • @AlexCohn That's true. But the thing is it is a cumbersome task to manually run the javac with the relevant comipler options every time. That is why i needed to add this step into the maven compiler plugin life cycle. But what you say is true it is always better to go through the diff before generating the headers.
    – Adiesha
    Nov 8 at 5:12










  • I am sorry you are stuck with the tools that are not up to date. I would expect better Java IDEs that will take full advantage of JDK 8 and later. Also, if your native interface is not stable, consider shifting from pure JNI to more flexible frameworks. Examples are djinni, SWIG, JNA, and more.
    – Alex Cohn
    Nov 8 at 7:28















up vote
1
down vote

favorite












I already tried passing this argument in the pom but it does not recognize it. Since jdk 8 we dont have to manually run javah to generate header files rather we can pass -h argument to javac and generate the header files when compiling. So if I can pass "-h dir" to maven compiler plugin I can generate the header files when I run mvn compile



<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-verbose</arg>
<arg>-h .</arg>
</compilerArgs>
</configuration>
</plugin>


But when I run mvn install I get this



[INFO] BUILD FAILURE



[INFO] ------------------------------------------------------------------------



[INFO] Total time: 2.936 s



[INFO] Finished at: 2018-11-07T14:52:49+05:30



[INFO] Final Memory: 9M/155M



[INFO]------------------------------------------------------------------------



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project adiesha-native: Fatal error compiling: invalid flag: -h . -> [Help 1]



Is there any other way to do this with maven or do i have to manually create them using "javac -h dir"



Any help would be greatly appreciated










share|improve this question




















  • 1




    try <arg>-h</arg> <arg>.</arg> (two args). And please dont post links to screenshots on SO, rather paste the real code in the question (most people will not bother to click on external links)
    – Gyro Gearless
    Nov 7 at 9:13










  • @GyroGearless Thanks It worked. I will edit the post. (Thanks for the advice)
    – Adiesha
    Nov 7 at 9:20










  • I would rather run javac -h manually. Having the automagically synchronized headers is, most likely, not enough. If something changes in the interface, you will need to adjust the C++ implementations, too. It may be nice to verify that the autogenerated headers are not changed, but this involves a separate custom build step to run diff against the current git copy of same header files.
    – Alex Cohn
    Nov 7 at 12:37










  • @AlexCohn That's true. But the thing is it is a cumbersome task to manually run the javac with the relevant comipler options every time. That is why i needed to add this step into the maven compiler plugin life cycle. But what you say is true it is always better to go through the diff before generating the headers.
    – Adiesha
    Nov 8 at 5:12










  • I am sorry you are stuck with the tools that are not up to date. I would expect better Java IDEs that will take full advantage of JDK 8 and later. Also, if your native interface is not stable, consider shifting from pure JNI to more flexible frameworks. Examples are djinni, SWIG, JNA, and more.
    – Alex Cohn
    Nov 8 at 7:28













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I already tried passing this argument in the pom but it does not recognize it. Since jdk 8 we dont have to manually run javah to generate header files rather we can pass -h argument to javac and generate the header files when compiling. So if I can pass "-h dir" to maven compiler plugin I can generate the header files when I run mvn compile



<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-verbose</arg>
<arg>-h .</arg>
</compilerArgs>
</configuration>
</plugin>


But when I run mvn install I get this



[INFO] BUILD FAILURE



[INFO] ------------------------------------------------------------------------



[INFO] Total time: 2.936 s



[INFO] Finished at: 2018-11-07T14:52:49+05:30



[INFO] Final Memory: 9M/155M



[INFO]------------------------------------------------------------------------



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project adiesha-native: Fatal error compiling: invalid flag: -h . -> [Help 1]



Is there any other way to do this with maven or do i have to manually create them using "javac -h dir"



Any help would be greatly appreciated










share|improve this question















I already tried passing this argument in the pom but it does not recognize it. Since jdk 8 we dont have to manually run javah to generate header files rather we can pass -h argument to javac and generate the header files when compiling. So if I can pass "-h dir" to maven compiler plugin I can generate the header files when I run mvn compile



<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<compilerArgs>
<arg>-verbose</arg>
<arg>-h .</arg>
</compilerArgs>
</configuration>
</plugin>


But when I run mvn install I get this



[INFO] BUILD FAILURE



[INFO] ------------------------------------------------------------------------



[INFO] Total time: 2.936 s



[INFO] Finished at: 2018-11-07T14:52:49+05:30



[INFO] Final Memory: 9M/155M



[INFO]------------------------------------------------------------------------



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project adiesha-native: Fatal error compiling: invalid flag: -h . -> [Help 1]



Is there any other way to do this with maven or do i have to manually create them using "javac -h dir"



Any help would be greatly appreciated







java maven jni javah






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 9:24

























asked Nov 7 at 9:08









Adiesha

63




63








  • 1




    try <arg>-h</arg> <arg>.</arg> (two args). And please dont post links to screenshots on SO, rather paste the real code in the question (most people will not bother to click on external links)
    – Gyro Gearless
    Nov 7 at 9:13










  • @GyroGearless Thanks It worked. I will edit the post. (Thanks for the advice)
    – Adiesha
    Nov 7 at 9:20










  • I would rather run javac -h manually. Having the automagically synchronized headers is, most likely, not enough. If something changes in the interface, you will need to adjust the C++ implementations, too. It may be nice to verify that the autogenerated headers are not changed, but this involves a separate custom build step to run diff against the current git copy of same header files.
    – Alex Cohn
    Nov 7 at 12:37










  • @AlexCohn That's true. But the thing is it is a cumbersome task to manually run the javac with the relevant comipler options every time. That is why i needed to add this step into the maven compiler plugin life cycle. But what you say is true it is always better to go through the diff before generating the headers.
    – Adiesha
    Nov 8 at 5:12










  • I am sorry you are stuck with the tools that are not up to date. I would expect better Java IDEs that will take full advantage of JDK 8 and later. Also, if your native interface is not stable, consider shifting from pure JNI to more flexible frameworks. Examples are djinni, SWIG, JNA, and more.
    – Alex Cohn
    Nov 8 at 7:28














  • 1




    try <arg>-h</arg> <arg>.</arg> (two args). And please dont post links to screenshots on SO, rather paste the real code in the question (most people will not bother to click on external links)
    – Gyro Gearless
    Nov 7 at 9:13










  • @GyroGearless Thanks It worked. I will edit the post. (Thanks for the advice)
    – Adiesha
    Nov 7 at 9:20










  • I would rather run javac -h manually. Having the automagically synchronized headers is, most likely, not enough. If something changes in the interface, you will need to adjust the C++ implementations, too. It may be nice to verify that the autogenerated headers are not changed, but this involves a separate custom build step to run diff against the current git copy of same header files.
    – Alex Cohn
    Nov 7 at 12:37










  • @AlexCohn That's true. But the thing is it is a cumbersome task to manually run the javac with the relevant comipler options every time. That is why i needed to add this step into the maven compiler plugin life cycle. But what you say is true it is always better to go through the diff before generating the headers.
    – Adiesha
    Nov 8 at 5:12










  • I am sorry you are stuck with the tools that are not up to date. I would expect better Java IDEs that will take full advantage of JDK 8 and later. Also, if your native interface is not stable, consider shifting from pure JNI to more flexible frameworks. Examples are djinni, SWIG, JNA, and more.
    – Alex Cohn
    Nov 8 at 7:28








1




1




try <arg>-h</arg> <arg>.</arg> (two args). And please dont post links to screenshots on SO, rather paste the real code in the question (most people will not bother to click on external links)
– Gyro Gearless
Nov 7 at 9:13




try <arg>-h</arg> <arg>.</arg> (two args). And please dont post links to screenshots on SO, rather paste the real code in the question (most people will not bother to click on external links)
– Gyro Gearless
Nov 7 at 9:13












@GyroGearless Thanks It worked. I will edit the post. (Thanks for the advice)
– Adiesha
Nov 7 at 9:20




@GyroGearless Thanks It worked. I will edit the post. (Thanks for the advice)
– Adiesha
Nov 7 at 9:20












I would rather run javac -h manually. Having the automagically synchronized headers is, most likely, not enough. If something changes in the interface, you will need to adjust the C++ implementations, too. It may be nice to verify that the autogenerated headers are not changed, but this involves a separate custom build step to run diff against the current git copy of same header files.
– Alex Cohn
Nov 7 at 12:37




I would rather run javac -h manually. Having the automagically synchronized headers is, most likely, not enough. If something changes in the interface, you will need to adjust the C++ implementations, too. It may be nice to verify that the autogenerated headers are not changed, but this involves a separate custom build step to run diff against the current git copy of same header files.
– Alex Cohn
Nov 7 at 12:37












@AlexCohn That's true. But the thing is it is a cumbersome task to manually run the javac with the relevant comipler options every time. That is why i needed to add this step into the maven compiler plugin life cycle. But what you say is true it is always better to go through the diff before generating the headers.
– Adiesha
Nov 8 at 5:12




@AlexCohn That's true. But the thing is it is a cumbersome task to manually run the javac with the relevant comipler options every time. That is why i needed to add this step into the maven compiler plugin life cycle. But what you say is true it is always better to go through the diff before generating the headers.
– Adiesha
Nov 8 at 5:12












I am sorry you are stuck with the tools that are not up to date. I would expect better Java IDEs that will take full advantage of JDK 8 and later. Also, if your native interface is not stable, consider shifting from pure JNI to more flexible frameworks. Examples are djinni, SWIG, JNA, and more.
– Alex Cohn
Nov 8 at 7:28




I am sorry you are stuck with the tools that are not up to date. I would expect better Java IDEs that will take full advantage of JDK 8 and later. Also, if your native interface is not stable, consider shifting from pure JNI to more flexible frameworks. Examples are djinni, SWIG, JNA, and more.
– Alex Cohn
Nov 8 at 7:28

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186355%2fhow-can-i-pass-h-argument-to-maven-compiler-plugin-to-create-jni-header-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186355%2fhow-can-i-pass-h-argument-to-maven-compiler-plugin-to-create-jni-header-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()