如何方便地为最终用户启动Java GUI程序 [英] How to start Java GUI program conveniently for the end user
问题描述
用户希望从Windows 启动Java GUI应用程序,并附加一些额外的JVM参数。
例如:
The user wants to start the Java GUI application from Windows, with some amount of additional JVM parameters.
For instance:
javaw -Djava.util.logging.config.file=logging.properties -jar MyGUI.jar
如果将上述行添加到批处理文件,用户可以双击批处理文件名。
这很酷。但是有一个令人讨厌的副作用:批量文件在启动GUI 之前打开 cmd 窗口。
If I add the above line to the batch file, the user can double-click the batch-file name.
And it's cool. But there is one annoying side effect: the batch file opens the cmd window before starting the GUI.
是有一个简单的方式可以通过双击批处理文件(或其他适合上述需要的其他文件)来启动Java GUI应用程序,而不打开 cmd 窗口? / p>
Is there a simple way to start the java GUI application by double-clicking the batch-file (or some other file which suits the above needs) without opening the cmd window?
推荐答案
我看到了很多方法:
- 使用 Launch4J 生成的启动器(感谢CodeBrickie的提示)或 Install4J / Exe4J 。 Launch4J允许您通过创建与exe相同名称的
.l4j.ini
文件来调整参数。在Exe4J的情况下,可以在生成的exe旁边的.vmoptions
文件中指定额外的参数。 - 创建一个将javaw.exe的快捷方式提供给您所需的图标,将开始字段设置为应用程序的目录,并在目标字段中指定参数到javaw。
- 启动javaw的VB脚本。如果VBS运行时设置为使用 wscript ,则不会弹出控制台窗口。
- 如果使用Java Web Start,您可能希望让用户进行调整在具有参数的Java Webstart 中指定的JNLP文件。
- Use a launcher as generated by Launch4J (thanks to CodeBrickie for the tip) or Install4J/Exe4J. Launch4J allows you to tweak the parameters by creating an
.l4j.ini
file with the same name as the exe. In case of Exe4J, extra parameters can be specified in a.vmoptions
file which you drop next to the generated exe. - Create a Shortcut to javaw.exe, give it the icon you want, set the "Start in" field to the directory of the application and specify your parameters to javaw in the Target field.
- Make a VB script which launches javaw. If the VBS runtime is set to use wscript, no console window will pop up.
- If you use Java Web Start, you might want to let the user tweak the JNLP file as specified in Java Webstart with parameters.
这篇关于如何方便地为最终用户启动Java GUI程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!