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
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.
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?
Commonly Used Methods in All GUI ComponentsString getText(), void setText(String s) -- accessor methods for the text of labels, buttons, text fields and text areas. void setBackground(Color c) -- sets the background color of a component.
What is GUI in Java? GUI (Graphical User Interface) in Java is an easy-to-use visual experience builder for Java applications. It is mainly made of graphical components like buttons, labels, windows, etc. through which the user can interact with an application.
Creating a GUI is a great way to get experience working with objects in Java because each interface component is represented by its own class. To use an interface component in Java, you create an object of that component's class. You already have worked with the container class JFrame.
I see a number of ways:
.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.Try
start javaw -Djava.util.logging.config.file=logging.properties -jar MyGUI.jar
You can also use 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)
Finally, there are general-purpose utilities you can use to hide windows, such as CMDOW and Hidden Start ($20). I have not used either myself, since start
does the same thing.
The user wants to start the Java GUI application ..
The best user experience for the end user will be offered by launching the app. using Java Web Start. JWS can install desktop shortcuts and menu items to launch the app.
..from Windows..
JWS also works on OS X & *nix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With