0

I've written a small java program that required user input for login, to do other stuff. Executing the .jar file of my program masks the password as expected.

However, when I create a .exe from the same .jar and run it, the application doesn't mask the password. What should I do to make the .exe mask the password?

Console cons = System.console();
        if (cons == null) {
            System.err.println("No console.");
            System.exit(1);
        }
        String username = cons.readLine("Enter username: ");
        char[] passwd = cons.readPassword("Enter Password: ");
        String password = new String(passwd);

I'm using Console.readPassword to mask the password and I used lanuch4j to create my .exe

1 Answers1

0

Even if it is a command line only application, it may be possible for you to show a dialog popup just for user credentials, as discussed here. The only case this would not work is if GUI is not available (remote text-only session or some server without GUI installed).

Community
  • 1
  • 1
Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93