Java library for creating console commands
You could use a parser to do this. You want to take some free form text and convert it into appropriate Java objects that represent the expression the user typed in.
There are many libraries available from the heavyweight (AntLR for example) to something simpler (like JParsec). You have also always got the option of doing it manually with regular expressions and so on.
You might want to look at JLine. It is similar to BSD editline and GNU readline.