0
 @Override
public void run() {

  while (true) {
    try {
       if (System.in.read() == 'q') {
       // some ations..
        }
    } catch (IOException e) {
    e.printStackTrace();
    }

}

Method main implements Runnable and wait key pressed, instead of 'q' must be esc

Chickin Nick
  • 517
  • 1
  • 6
  • 21
  • method main implements Runnable .... Methods can't implement interfaces, only classes can. I doubt this is possible with only the jdk, since you would need to check a value from an event, while the command line doesn't work with events. – Stultuske May 17 '15 at 11:46
  • 2
    Basically, you can't. The console only passes "cooked" text to Java. (There are platform-dependent, not-entirely-reliable ways of overcoming this. Unless you know exactly what you are doing, I recommend staying away from them). – RealSkeptic May 17 '15 at 11:47
  • i'm sorry, i means class, contains main – Chickin Nick May 17 '15 at 11:50

0 Answers0