栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何使JRE与launch4j捆绑在一起?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何使JRE与launch4j捆绑在一起?

更新:删除了我以前的答案,并用经过测试的工作示例代替

更新2:现在,此pom.xml下载JRE tgz并将其解压缩,并且launch4jexe使用它并且可以工作。我添加了评论来解释它是如何工作的。

我建议只使用32位exe和JRE。使用64位JRE的唯一原因是程序需要使用超过4 GB的RAM。

当然,现在您需要一个安装程序来接收所有这些内容并安装到ProgramFiles。过去,我已使用NSIS。NSIS有一个学习曲线,但还不错。

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <groupId>com.akathist.encc</groupId>    <artifactId>mavenproject1</artifactId>    <version>1.0-SNAPSHOT</version>    <packaging>jar</packaging>    <properties>        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>        <maven.compiler.source>1.8</maven.compiler.source>        <maven.compiler.target>1.8</maven.compiler.target>    </properties>    <dependencies>        <!-- This is the win32 JRE tgz hosted by alfresco - https://mvnrepository.com/artifact/com.oracle.java/jre -->        <dependency> <groupId>com.oracle.java</groupId> <artifactId>jre</artifactId> <classifier>win32</classifier> <type>tgz</type> <version>1.8.0_131</version>        </dependency>    </dependencies>    <repositories>        <repository> <!-- this repository has the JRE tgz --> <id>alfresco</id> <url>https://artifacts.alfresco.com/nexus/content/repositories/public/</url>        </repository>    </repositories>    <build>        <plugins> <plugin>     <!-- this is to extract the JRE tgz file we downloaded -->     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-dependency-plugin</artifactId>     <version>2.5.1</version>     <executions>         <execution>  <phase>generate-resources</phase>  <goals>      <goal>unpack-dependencies</goal>  </goals>  <configuration>      <includeGroupIds>com.oracle.java</includeGroupIds>      <includeTypes>tgz</includeTypes>      <includeArtifactIds>jre</includeArtifactIds>      <includeClassifiers>win32</includeClassifiers>      <outputDirectory>target/win32</outputDirectory>  </configuration>         </execution>     </executions> </plugin> <plugin>     <!-- This calls launch4j to create the program EXE -->     <groupId>com.akathist.maven.plugins.launch4j</groupId>     <artifactId>launch4j-maven-plugin</artifactId>     <executions>         <execution>  <id>l4j-clui</id>  <phase>package</phase>  <goals>      <goal>launch4j</goal>  </goals>  <configuration>      <headerType>console</headerType>      <outfile>target/encc.exe</outfile>      <jar>target/mavenproject1-1.0-SNAPSHOT.jar</jar>      <errTitle>encc</errTitle>      <classPath>          <mainClass>com.akathist.encc.Clui</mainClass>          <addDependencies>false</addDependencies>          <preCp>anything</preCp>      </classPath>      <jre>          <path>./win32/java</path>      </jre>      <versionInfo>          <fileVersion>1.2.3.4</fileVersion>          <txtFileVersion>txt file version?</txtFileVersion>          <fileDescription>a description</fileDescription>          <copyright>my copyright</copyright>          <productVersion>4.3.2.1</productVersion>          <txtProductVersion>txt product version</txtProductVersion>          <productName>E-N-C-C</productName>          <internalName>ccne</internalName>          <originalFilename>original.exe</originalFilename>      </versionInfo>  </configuration>         </execution>     </executions> </plugin>        </plugins>    </build></project>

更新3:可悲的事实是,您所需要的JRE不存在任何官方的甚至最新的Maven存储库。您可以托管自己的具有所需JRE的Maven存储库。随着新版本的完成,您将必须更新此内容。在发布新版本之前进行测试也是一个好主意。每个月的第三个星期二是新Java版本发布的时间。您可以为此设置提醒,以检查是否发布了新版本并下载。由于需要进行许可协议检查,因此将其自动化是很痛苦的。这篇文章可能会有所帮助,但您可能无法通过这种方式下载JRE的tar.gz版本:Java以编程方式检查最新版本

如果要支持多个平台,则托管自己的Maven存储库是一个不错的方法。您可以托管自己的存储库,并在每次发布完成后使用新的JREtar.gz更新它:http://codingdict.com/questions/144877

最简单的选择是做您已经打算的目标,然后只使用构建您的JRE。只要您使用32位JRE进行构建,就可以支持Windows
32和64。您有时间测试新版本时,可以偶尔进行更新。这是一个可以执行此操作的pom.xml:

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>    <groupId>com.akathist.encc</groupId>    <artifactId>mavenproject1</artifactId>    <version>1.0-SNAPSHOT</version>    <packaging>jar</packaging>    <properties>        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>        <maven.compiler.source>1.8</maven.compiler.source>        <maven.compiler.target>1.8</maven.compiler.target>    </properties>    <build>        <plugins> <plugin>     <!-- This copies the JRE used to do the build from java.home - should be 32 bit Windows JRE -->     <artifactId>maven-resources-plugin</artifactId>     <version>2.6</version>     <executions>         <execution>  <id>copy-resources</id>  <!-- here the phase you need -->  <phase>package</phase>  <goals>      <goal>copy-resources</goal>  </goals>  <configuration>      <outputDirectory>${basedir}/target/win32/java</outputDirectory>      <resources>          <resource>   <directory>${java.home}</directory>          </resource>      </resources>  </configuration>         </execution>     </executions> </plugin> <plugin>     <!-- This calls launch4j to create the program EXE -->     <groupId>com.akathist.maven.plugins.launch4j</groupId>     <artifactId>launch4j-maven-plugin</artifactId>     <executions>         <execution>  <id>l4j-clui</id>  <phase>package</phase>  <goals>      <goal>launch4j</goal>  </goals>  <configuration>      <headerType>console</headerType>      <outfile>target/encc.exe</outfile>      <jar>target/mavenproject1-1.0-SNAPSHOT.jar</jar>      <errTitle>encc</errTitle>      <classPath>          <mainClass>com.akathist.encc.Clui</mainClass>          <addDependencies>false</addDependencies>          <preCp>anything</preCp>      </classPath>      <jre>          <path>./win32/java</path>      </jre>      <versionInfo>          <fileVersion>1.2.3.4</fileVersion>          <txtFileVersion>txt file version?</txtFileVersion>          <fileDescription>a description</fileDescription>          <copyright>my copyright</copyright>          <productVersion>4.3.2.1</productVersion>          <txtProductVersion>txt product version</txtProductVersion>          <productName>E-N-C-C</productName>          <internalName>ccne</internalName>          <originalFilename>original.exe</originalFilename>      </versionInfo>  </configuration>         </execution>     </executions> </plugin>        </plugins>    </build></project>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/570478.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号