In my program i want some task to run when user pressed any key.i am running my program in console mode.how to identify when user press any key.please help.
Can't be done in the J2SE. The stream from the console is buffered, so we only get data after a line feed (i.e. after the user presses "enter"). I've done it using JNI, but really, if you want a fully-featured GUI, use AWT or Swing.