Skip to content

Instantly share code, notes, and snippets.

@samundra
Last active August 7, 2016 14:16
Show Gist options
  • Save samundra/8581835c28b9ce3d8827 to your computer and use it in GitHub Desktop.
Save samundra/8581835c28b9ce3d8827 to your computer and use it in GitHub Desktop.
Instruction to compile java program from command line which resides inside package
/**
* Filename : ConsolePassword.java
* @package : com.fivedots
*
* ConsolePassword is inside "Hello" project. Thus CD into the folder first, my case its "F:\workspace\Hello\"
* - cd F:\workspace\Hello
* - cd src
* - javac "com/fivedots/ConsolePassword.java"
* - java com.fivedots.ConsolePassword
**/
import java.io.Console;
public class ConsolePassword {
public static void main(String[] args) {
Console cons = System.console();
String username = cons.readLine("Enter username: ");
char[] passwd = cons.readPassword("Enter password: ");
System.out.println("Username :"+username);
System.out.println("password :"+passwd);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment