Решение на основе BeanShell и JConsole
BeanShell JAR - beanshell.org/download
Мануалы по JConsole - beanshell.org/manual/jconsole
Пример на основе BeanShell и JConsole:
/**
* Print prompt and echos commands entered via the JConsole
*
* @param console a GUIConsoleInterface which in addition to
* basic input and output also provides coloured text
* output and name completion
* @param prompt text to display before each input line
*/
private static void inputLoop(GUIConsoleInterface console, String prompt) {
Reader input = console.getIn();
BufferedReader bufInput = new BufferedReader(input);
String newline = System.getProperty("line.separator");
console.print(prompt, Color.BLUE);
String line;
try {
while ((line = bufInput.readLine()) != null) {
console.print("You typed: " + line + newline, Color.ORANGE);
// try to sync up the console
//System.out.flush();
//System.err.flush();
//Thread.yield(); // this helps a little
if (line.equals("quit")) break;
console.print(prompt, Color.BLUE);
}
bufInput.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Оригинальный пост