How to run end user Java GUI program

The user wants to run the Java GUI application from Windows with some additional JVM options.
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 this is awesome. But there is one annoying side effect: the batch file opens the cmd window before starting the GUI .

Is there an easy way to launch a Java GUI application by double-clicking the batch file (or another file that meets the above requirements) without opening the cmd window?

+5
source share
4 answers

I see several ways:

  • Use the launcher created by Launch4J (thanks to CodeBrickie for a hint) or Install4J / Exe4J . Launch4J allows you to configure settings by creating a file .l4j.iniwith the same name as exe. In the case of Exe4J, additional parameters can be specified in the file .vmoptionsthat you drop next to the created exe.
  • Create a shortcut for javaw.exe, give it the desired icon, set the "Start in" field to the application directory and specify your parameters for javaw in the Target field.
  • Create a VB script that runs javaw. If the VBS runtime is set to wscript, the console window does not appear.
  • Java Web Start, JNLP, Java Webstart .
+6

Try

start javaw -Djava.util.logging.config.file=logging.properties -jar MyGUI.jar

scripting:

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:

var WindowStyle_Hidden = 0
var objShell = WScript.CreateObject("WScript.Shell")
var result = objShell.Run("cmd.exe /c abc.bat", WindowStyle_Hidden)

, , , CMDOW ($ 20). , start .

+3

Java GUI.

The best user interface for the end user will be offered when the application starts. using Java Web Start . JWS can set desktop shortcuts and menu items to launch the application.

.. from Windows ..

JWS also works with OS X and * nix.

+3
source

Lauch4j can wrap your jar in an exe file.

+2
source

All Articles