Possible Duplicate:
How to listen to keyboard events in a console application
Hi I am new to java syntax.I am trying to invoke an action on a keystroke like “ENTER key”
For ex:
on pressing Enter key {
int c = 9+8 ; //This should run on pressing enter key but not just running program directly
printf("c");
}
I have referred few java doc relating to this and tried to execute the code.But I face few syntax errors. Can any one give direct example
On a command line application, I believe you’d have to parse input from
System.in. If you are only wanting to supply initial parameters, there are libraries out there that can do this for you to make your life easier such as Commons CLI. If you are running from the command line, you will be compiling your code to a .jar file. This library should let you supply flags, and named arguments to your java classes within your jar file.To output text to the command prompt, use System.out.