windows 如何使 Java 应用程序独立?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2712768/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:21:07  来源:igfitidea点击:

How to make Java application standalone?

javawindowsdeploymentsoftware-distribution

提问by rakete

I have to burn a Java application on a CD. This application have to run on every Windows PC wihtout any installation (also JRE shouldn't be installed) before.

我必须在 CD 上刻录 Java 应用程序。此应用程序必须在每台 Windows PC 上运行而无需任何安装(也不应安装 JRE)。

回答by ZeissS

I guess you could copy the JRE from your programs folder onto the CD too. Then, add a batch script to use your "local" JRE to start your app. That should be enough, but I don't know if this works with all versions of windows.

我想您也可以将 JRE 从您的程序文件夹复制到 CD 上。然后,添加一个批处理脚本以使用您的“本地”JRE 来启动您的应用程序。这应该足够了,但我不知道这是否适用于所有版本的 Windows。

回答by Marko

You'd have to bundle jre on disk and create startup scripts. If you are not satisfied with simple batch / shell startup scripts you can use something like JLauncher to create "real" executable.

您必须在磁盘上捆绑 jre 并创建启动脚本。如果您对简单的批处理/shell 启动脚本不满意,您可以使用 JLauncher 之类的工具来创建“真正的”可执行文件。

回答by Xorty

JSmoothcan do the trick with bundling JRE or prompting install Java, and it is free. You can also set properties for JVM

JSmooth可以通过捆绑 JRE 或提示安装 Java 来解决这个问题,而且它是免费的。您还可以为 JVM 设置属性

回答by Michael Borgwardt

The easiest way would be to include an unpacked Java installation on the CD and use it to run the application.

最简单的方法是在 CD 上包含一个未打包的 Java 安装并使用它来运行应用程序。

There are AFAIK only 2 "Java to exe" compilers still on the market, one of which (Excelsior JET) is quite expensive, and the other (GCJ) doesn't work on Programs that use AWT or Swing.

AFAIK 市场上只有 2 个“Java 到 exe”编译器,其中一个 (Excelsior JET) 非常昂贵,另一个 (GCJ) 不适用于使用 AWT 或 Swing 的程序。

回答by Georg Edelmann

Just burn a jre onto the cd as well and start your application inside a batch script, which sets the CLASSPATH and the JAVA_HOME variables pointing to your jre.

只需将 jre 也刻录到 cd 上并在批处理脚本中启动您的应用程序,该脚本设置 CLASSPATH 和指向您的 jre 的 JAVA_HOME 变量。