[英]How to start Java GUI program conveniently for the end user
The user wants to start the Java GUI application from Windows , with some amount of additional JVM parameters. 用户希望从Windows启动Java GUI应用程序,并添加一些额外的JVM参数。
For instance: 例如:
javaw -Djava.util.logging.config.file=logging.properties -jar MyGUI.jar
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 .
但是有一个恼人的副作用: 批处理文件在启动GUI之前打开cmd窗口 。
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? 是否有一种简单的方法可以通过双击批处理文件(或其他适合上述需要的文件)来启动java GUI应用程序而无需打开cmd窗口?
I see a number of ways: 我看到了很多方法:
.l4j.ini
file with the same name as the exe. .l4j.ini
文件来调整参数。 In case of Exe4J, extra parameters can be specified in a .vmoptions
file which you drop next to the generated exe. .vmoptions
文件中指定额外的参数,该文件将放在生成的exe旁边。 Try 尝试
start javaw -Djava.util.logging.config.file=logging.properties -jar MyGUI.jar
You can also use scripting : 您还可以使用脚本 :
VBS: VBS:
Const HIDDEN_WINDOW = 12
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create("Notepad.exe", null, objConfig, intProcessID)
JScript: JScript的:
var WindowStyle_Hidden = 0
var objShell = WScript.CreateObject("WScript.Shell")
var result = objShell.Run("cmd.exe /c abc.bat", WindowStyle_Hidden)
Finally, there are general-purpose utilities you can use to hide windows, such as CMDOW and Hidden Start ($20) . 最后,您可以使用通用实用程序来隐藏窗口,例如CMDOW和Hidden Start(20美元) 。 I have not used either myself, since
start
does the same thing. 我没有使用过自己,因为
start
做同样的事情。
The user wants to start the Java GUI application ..
用户想要启动Java GUI应用程序..
The best user experience for the end user will be offered by launching the app. 通过启动应用程序,将为最终用户提供最佳用户体验。 using Java Web Start .
使用Java Web Start 。 JWS can install desktop shortcuts and menu items to launch the app.
JWS可以安装桌面快捷方式和菜单项来启动应用程序。
..from Windows..
..来自Windows ..
JWS also works on OS X & *nix. JWS也适用于OS X&* nix。
Lauch4j可以将你的jar包装在exe文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.