简体   繁体   English

用于Java应用程序的JRE包

[英]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-pluginjavapackager 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.

相关问题 将JRE与Java应用程序捆绑在一起 - Bundling the JRE with a Java application 是否有一个工具可以将JRE的副本与我的应用程序打包在一起,以便无论用户是否安装了Java,它都可以运行? - Is there a tool which will package a copy of the JRE with my application so that it can run regardless of whether or not the user has Java installed? 如何使用java应用程序检查jre版本 - how to check jre version using java application 修复Java代码中的JRE错误并重新编译应用程序 - Fixing JRE error in Java code and recompiling application 为Java WebStart应用程序指定JRE位置 - Specifying JRE location for Java WebStart application 如何使用特定的JRE交付我的Java应用程序? - How to deliver my Java application with a particular JRE? Java JNA:应用程序完成后JRE崩溃 - Java JNA: JRE crashes after application completes 如何将 Java 相关应用程序与 MSI 中的 JRE 捆绑在一起 - How to bundle a Java dependent application with a JRE in an MSI 我有一个Java应用程序在JRE 6中运行,但不在JRE 7中运行。如何在JRE7中运行该应用程序 - I have a Java App running in JRE 6 but not in JRE 7. How do i run the application in JRE7 如何在Windows中为目标UNIX计算机在应用程序中打包JRE - How to package JRE with application in windows for target UNIX machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM