I have an application that needs user input for password.
What i want to do is to either read the password from console (if the OS supports one e.g unix) or display a JOptionPane and ask the user to enter his password (if the OS supports graphical interface e.g windows).
Some people may argue that a console will always be available in both the above cases so a console input will be sufficient. But problem is if the Java app starts using javaw.exe then a console is not available. Thus, i need a way to determine if i can do either case.
My problem is how to determine if the environment that the application runs from supports either a console or a graphical interface.
I know that a static method exists
GraphicsEnvironment.isHeadless()
but from the Java doc i think that this method cannot distinguish if the OS supports graphics, but rather than if the OS can support one of the I/O devices (keyboard, mouse, screen).
Does anyone know more about this? Am i able to retrieve if the OS supports console or graphics environment?
Thanks in advance.