Since you haven't posted a stacktrace, the only line that can have return a null
value is this one:
Console console = System.console();
Noted by your comment: I'm running glassfish in Netbeans. So, this line will throw a NullPointerException
:
console.printf("mail : %s\npassword: %s\n", username,password); //console is null
Try using a logger instead to print your messages. Just for a dirty quick solution, use System.out.println
instead until you happen to configure and use a logger. So, in short, replace these lines:
Console console = System.console();
console.printf("mail : %s\npassword: %s\n", username,password);
To:
System.out.printf("mail : %s\npassword: %s\n", username,password));