Your question is fairly broad...that doesn't work too well around here. If you have a specific, focused question, you'll get tons of help. Further, if you ShowSomeEffort, you will be more likely to get help. Otherwise, about all you'll get are broad suggestions and tips.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
The standard Java API for this is called JavaSpeech. However, while there are open source or free implementations of its speech synthesis part, I'm not aware of such implementations of the speech recognition part.