我是Java编程的新手,但我一般都熟悉一切是如何工作的.我希望能够将jar文件和jre放入windows可执行文件(exe)中,这样当我分发它时,客户端不需要安装JRE.我应该使用什么程序?
我有launch4j,它似乎正是我想要的,但是当我尝试运行应用程序时,我得到"这个应用程序被配置为使用捆绑的Java运行时环境,但运行时丢失或损坏."
我希望我的应用程序只是一个可运行的exe,而不是安装程序.至少,有人能告诉我如何正确地将一个JRE与launch4j捆绑在一起吗?
我知道launch4j没有捆绑JRE,.exe但你必须把它放在旁边.我的问题是,我该怎么做?有没有办法让maven自动定位和复制我用来构建我的应用程序并将其复制到给定目录的JDK的JRE?
我尝试过这样的事情:
<plugin>
<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/windows/jre</outputDirectory>
<resources>
<resource>
<directory>${java.home}</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但程序没有启动.它显示了一个立即消失的小对话框(它似乎是空白的,但它让我真的注意到它太快了).
我制作了一个可执行的 jar 文件,但我想将其分发给可能没有在计算机(Mac 或 PC)上安装 Java 的用户。作为程序员,我能做些什么来确保没有 Java 的人也能运行吗?
我正在尝试使用launch4j将JRE捆绑到我的exe中.
我的文件夹结构如下 -
|- test
|- jre(copied from my windows installation of jre)
|-bin
|-lib
|- jretest.jar (the jar file I am using to create my exe)
|- jretest.exe (the output exe file)
Run Code Online (Sandbox Code Playgroud)
在Launch4j中,我设置了Bundled JRE Pathas jre.
到目前为止exe工作正常.
但是,当我将我的exe文件复制到别处并运行它时,我收到错误消息This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted.
我搜索了SO并发现了以下问题,但无法让我的应用程序使用那里给出的建议.
如何将JRE捆绑到Java应用程序的EXE中?Launch4j说"运行时丢失或损坏."
知道这里捆绑的jre会出现什么问题吗?
我怎样才能创建一个独立的exe?
我不想为我的应用程序制作安装程序,只是打算运行它.
任何帮助将不胜感激.
我想在我的可执行jar.so中捆绑JRE,这个exe可以在任何系统中运行.我已经尝试过lunch4j来创建捆绑的JRE,但我们需要运送JRE和exe两者.但根据我的要求,我不应该使用任何安装程序.我不应该在客户端机器中提取jre.请帮助有一种方法将JRE放入jar并使其使用.
我正在使用 launch4j maven 插件为我的应用程序生成 .exe。我还想嵌入一个捆绑的 JRE。我成功地从我安装了 java 1.8.0_161 的电脑上成功实现了它。我现在的问题是,当我尝试从未安装 java 的虚拟机执行 .exe 时,出现此错误
CryptoAlertNews: This application requires a Java Runtime Environment 1.8.0_161
Run Code Online (Sandbox Code Playgroud)
为什么我做错了会发生这种情况?这是我在 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.panos</groupId>
<artifactId>com.panos</artifactId>
<version>1.0-SNAPSHOT</version>
<name>com.panos</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId> …Run Code Online (Sandbox Code Playgroud)