One option. Use System.in to get from standard input. Of course, unfortunately, if standard input has been redirected, then it won't be the keyboard.
Another option. Use System.console() to get the Console attached to the JVM -- which also can read from the keyboard. Of course, unfortunately, if the JVM is running in the background, then it won't have a console.
And BTW, perhaps it is a language translation thingy, but your original post was completely not clear. And even your follow up, is kinda open to interpretation. Next time, it may be a good idea to give more than a single sentence as your initial question.