如何为最终用户方便地启动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.
有没有打开 cmd 窗口的简单方式来启动Java GUI应用程序通过双击批处理文件(或一些其他文件适合上述需要) / 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。
- VB脚本启动javaw。如果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屋!