views:

541

answers:

2

Hi All,

I want to create a "Command Console" similar to the Windows Command Prompt, with command history, etc which is in a JPanel so that it can be added to a JFrame.

What I want to do is present the user with the prompt to allow them to execute commands.

What I have in mind is similar to the BeanShell Console, however I haven't be able to find the source code for the console.

+1  A: 

To include BeanShell into your application, add the .jar-files from the BeanShell download page to your Java project and see the BeanShell doc section "Calling Beanshell from your Application" for examples how to call Beanshell with direct calls or by evaluating the commands from your shell.

See also the Quickstart Guide for other ways and examples how to use BeanShell.

Kosi2801
I don't want to link to the BeanShell i want to create a console LIKE the BeanShell console
Kryten
If you want to create "something like BeanShell" this usually boils down to creating your own scripting language. This is a nontrivial task which involves some advanced topics of programming and grammar creation. If the terms "LL/LR Parser", SableCC, JavaCC, ANTLR, bison or yacc sound familiar to you, you're good to go. Usually it's MUCH easier integrating something already built by others (Beanshell allows extending with custom build stuff for example) unless you really want to dive into the theoretical basics of language creation. Which is actually quite interesting too, but complicated :)
Kosi2801
Ah, forgot. The SVN link to the BeanShell source is available at http://www.beanshell.org/developer.html
Kosi2801
A: 

BeanShell provides JConsole, a command line console that can be used in your own application WITHOUT the overhead of the rest of the BeanShell functionality. See my example of using it here: http://stackoverflow.com/questions/1255373/create-a-command-console/1324525#1324525

The BeanShell source is available via SVN from svn co http://ikayzo.org/svn/beanshell

For more info on JConsole see http://www.beanshell.org/manual/jconsole.html

tukushan