[英]Package JRE for Java application
My goal is to to package a standalone JRE alongside with my Java application via Maven, automatically. 我的目标是通过Maven自动将独立的JRE与我的Java应用程序一起打包。
In order to achieve this, I use exec-maven-plugin
and javapackager
from JDK. 为了实现这一点,我使用了JDK的exec-maven-plugin
和javapackager
。 My POM setting looks like this: 我的POM设置如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>package-jar2</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>
${env.JAVA_HOME}/bin/javapackager
</executable>
<arguments>
<argument>-deploy</argument>
<argument>-native</argument>
<argument>exe</argument>
<argument>-appclass</argument>
<argument>${app.main.class}</argument>
<argument>-srcdir</argument>
<argument>${project.build.directory}</argument>
<argument>-srcfiles</argument>
<argument>${project.build.directory}\${artifactId}-${version}.jar</argument>
<argument>-outdir</argument>
<argument>${project.build.directory}</argument>
<argument>-outfile</argument>
<argument>${project.artifactId}-${version}</argument>
<argument>-v</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Finally, the javapackager
emits following error: 最后, javapackager
发出以下错误:
[INFO] --- exec-maven-plugin:1.5.0:exec (package-jar2) @ cli-api ---
Error: Unknown argument: D:\Archiv\Dokumente\Entwicklung\PEProjekt\repository\core\cli-api\target
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: -1 (Exit value: -1)
The Unknown argument
seems to be my -srcdir
parameter. Unknown argument
似乎是我的-srcdir
参数。
What am I doing wrong? 我究竟做错了什么? I'd like to package my native JRE in target directory. 我想将我的本机JRE打包到目标目录中。
if you want to add the base jre to your bundle use ths 如果你想将基础jre添加到你的包中使用ths
<argument>-Bruntime</argument>
<argument>${env.JAVA_HOME}</argument>
-srcdir
is the directory of all your dependent files, so i you just need 1 exclude the -srcdir
and use -srcfiles
-srcdir
是所有依赖文件的目录,所以我只需要1 -srcdir
并使用-srcfiles
if you dont want to, add a path.separator to the end of it 如果你不想,请在它的末尾添加一个path.separator
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.