Java 如何将 .jar 转换为 .exe?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4330936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I convert a .jar to an .exe?
提问by Negrodamus12
I want to convert a .jar
to an .exe
for microsoft. Is there any program converter for this?
我想将转换.jar
到.exe
对微软。是否有任何程序转换器?
Also if there's one for Mac and Linux I would appreciate suggestions for those too.
另外,如果有 Mac 和 Linux 的,我也很感激这些建议。
回答by TheLQ
If your program is "publicly available non-commercial in nature" and has "a publicly available Web site that meets the basic quality standards", then you can try and get a free license of Excelsior. If its not then it's expensive, but still a viable option.
如果您的程序是“公开的非商业性质的”并且具有“符合基本质量标准的公开网站”,那么您可以尝试获得 Excelsior 的免费许可。如果不是,那么它很昂贵,但仍然是一个可行的选择。
Program: https://www.excelsiorjet.com
程序:https: //www.excelsiorjet.com
As a side note: Here's a study of all existing Jar to EXE programs, which is a bit depressing - https://www.excelsior-usa.com/articles/java-to-exe.html
作为旁注:这是对所有现有 Jar 到 EXE 程序的研究,这有点令人沮丧 - https://www.excelsior-usa.com/articles/java-to-exe.html
回答by Tim Bender
Despite this being against the general SO policy on these matters, this seems to be what the OP genuinely wants:
尽管这违反了关于这些问题的一般 SO 政策,但这似乎是 OP 真正想要的:
http://www.google.com/search?btnG=1&pws=0&q=java+executable+wrapper
http://www.google.com/search?btnG=1&pws=0&q=java+executable+wrapper
If you'd like, you could also try creating the appropriate batch or script file containing the single line:
如果您愿意,也可以尝试创建包含单行的适当批处理或脚本文件:
java -jar MyJar.jar
Or in many cases on windows just double clicking the executable jar.
或者在 Windows 上的许多情况下,只需双击可执行 jar。
回答by Matthieu
Launch4jworks on both Windows and Linux/Mac. But if you're running Linux/Mac, there is a way to embed your jar into a shell script that performs the autolaunch for you, so you have only one runnable file:
Launch4j适用于 Windows 和 Linux/Mac。但是,如果您运行的是 Linux/Mac,则有一种方法可以将您的 jar 嵌入到为您执行自动启动的 shell 脚本中,因此您只有一个可运行文件:
exestub.sh:
exestub.sh:
#!/bin/sh
MYSELF=`which "$ cat exestub.sh myrunnablejar.jar > myrunnable
$ chmod +x myrunnable
" 2>/dev/null`
[ $? -gt 0 -a -f "##代码##" ] && MYSELF="./##代码##"
JAVA_OPT=""
PROG_OPT=""
# Parse options to determine which ones are for Java and which ones are for the Program
while [ $# -gt 0 ] ; do
case in
-Xm*) JAVA_OPT="$JAVA_OPT " ;;
-D*) JAVA_OPT="$JAVA_OPT " ;;
*) PROG_OPT="$PROG_OPT " ;;
esac
shift
done
exec java $JAVA_OPT -jar $MYSELF $PROG_OPT
Then you create your runnable file from your jar:
然后你从你的 jar 创建你的可运行文件:
##代码##It works the same way launch4j works: because a jar has a zip format, which header is located at the endof the file. You can have any header you want (either binary executable or, like here, shell script) and run java -jar <myexe>
, as <myexe>
is a valid zip/jar file.
它的工作方式相同launch4j作品:因为一个罐子有一个zip格式,其头位于末尾的文件。你可以拥有任何你想要的头文件(二进制可执行文件,或者像这里的 shell 脚本)并运行java -jar <myexe>
,就像<myexe>
一个有效的 zip/jar 文件一样。
回答by Monny
JSmooth .exe wrapper
JSmooth .exe 包装器
JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your Java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself. When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a website.
JSmooth 是一个 Java 可执行文件包装器。它为您的 Java 应用程序创建本机 Windows 启动器(标准 .exe)。它使 Java 部署更加流畅和用户友好,因为它能够自己找到任何已安装的 Java VM。当没有可用的 VM 时,包装器可以自动下载并安装合适的 JVM,或者只是显示一条消息或将用户重定向到网站。
JSmooth provides a variety of wrappers for your java application, each of them having their own behavior: Choose your flavor!
JSmooth 为您的 Java 应用程序提供了多种包装器,每个包装器都有自己的行为:选择您的风格!
Download: http://jsmooth.sourceforge.net/
下载:http: //jsmooth.sourceforge.net/
JarToExe 1.8Jar2Exe is a tool to convert jar files into exe files. Following are the main features as describe on their website:
JarToExe 1.8Jar2Exe 是一个将 jar 文件转换为 exe 文件的工具。以下是其网站上描述的主要功能:
Can generate “Console”, “Windows GUI”, “Windows Service” three types of .exe files.
可以生成“Console”、“Windows GUI”、“Windows Service”三种类型的.exe文件。
Generated .exe files can add program icons and version information. Generated .exe files can encrypt and protect java programs, no temporary files will be generated when the program runs.
生成的 .exe 文件可以添加程序图标和版本信息。生成的.exe文件可以对java程序进行加密和保护,程序运行时不会产生临时文件。
Generated .exe files provide system tray icon support. Generated .exe files provide record system event log support. Generated windows service .exe files are able to install/uninstall itself, and support service pause/continue.
生成的 .exe 文件提供系统托盘图标支持。生成的 .exe 文件提供记录系统事件日志支持。生成的windows服务.exe文件可以自行安装/卸载,支持服务暂停/继续。
- New release of x64 version, can create 64 bits executives. (May 18, 2008)
- Both wizard mode and command line mode supported. (May 18, 2008)
- Download: http://www.brothersoft.com/jartoexe-75019.html
- 新发布的 x64 版本,可以创建 64 位执行程序。(2008 年 5 月 18 日)
- 支持向导模式和命令行模式。(2008 年 5 月 18 日)
- 下载:http: //www.brothersoft.com/jartoexe-75019.html
Executor
执行者
Package your Java application as a jar, and Executor will turn the jar into a Windows .exe file, indistinguishable from a native application. Simply double-clicking the .exe file will invoke the Java Runtime Environment and launch your application.
将您的 Java 应用程序打包为 jar,Executor 会将 jar 转换为 Windows .exe 文件,与本机应用程序无法区分。只需双击 .exe 文件即可调用 Java 运行时环境并启动您的应用程序。