<section>
<name filename="commands">BeanShell Commands</name>

BeanShell commands appear to the user as pre-defined methods such as 
print(), load(), or save().
BeanShell Commands can be implemented as scripted methods or compiled Java 
classes which are dynamically loaded on demand from the classpath.
We'll talk about adding your own commands in the next section "Adding BeanShell Commands".
<p/>

<tip>
You can easily override any BeanShell command simply by defining the method
yourself in your script.  For example:
<p/>
<pre>
print( arg ) {
    System.out.println( "You printed: " + arg );
}
</pre>
<p/>
If you define the method in the global scope it will apply everywhere.  If you
define it local to a scripted object it will only apply in that object context.
</tip>

<h2>Commands Overview</h2>

This is a high level overview of the BeanShell command set.
You can find full documentation for all BeanShell commands in the "BeanShell
Commands Documentation" section of this manual.  See also the "BshDoc" 
section which covers javadoc style documentation of BeanShell script files.
<p/>

<h3>Interpreter Modes</h3>

The following commands affect general modes of operation of the interpreter.

<table border="1" cellpadding="5">
<tr><td>exit()</td><td>
Exit the interpreter.  (Also Control-D).
</td></tr>
<tr><td>show()</td><td>
Turn on "show" mode which prints the result of every
evaluation that is not of void type.
</td></tr>
<tr><td>setAccessibility()</td><td>
Turn on access to private and protected members of Java classes.
</td></tr>
<tr><td>server()</td><td>
Launch the remote access mode, allowing remote access
to the interpreter from a web browser or telnet client.
</td></tr>
<tr><td>debug()</td><td>
Turns on debug mode.  Note: this is very verbose, 
unstructured output and is primarily of interest to developers.
</td></tr>
<tr><td>setStrictJava()</td><td>
Turn on "strict Java" mode which enforces Java
compatibility by dissallowing loose types and undeclared variables.
</td></tr>
</table>

<p/><h3>Output</h3>

The following commands are used for output:

<table border="1" cellpadding="5">
<tr><td>print(), error()</td><td>
Print output to standard out or standard error.  print() always goes to the
console, whereas System.out may or may not be captured by a GUI console
or servlet.
</td></tr>
<tr><td>frame()</td><td>
Display the AWT or Swing component in a Frame
</td></tr>
</table>

<p/><h3>Source and Evaluation</h3>

The following commands are used for evaluation or to run external scripts or
applications:

<table border="1" cellpadding="5">
<tr><td>eval()</td><td>
Evaluate a string as if it were typed in the current scope.
</td></tr>
<tr><td>source(), sourceRelative()</td><td>
Read an external script file into the interpreter and evaluate it in the
current scope
</td></tr>
<tr><td>run(), bg()</td><td>
Run an external file in a subordinate interpreter or in a background
thread in a subordinate interpreter.
</td></tr>
<tr><td>exec()</td><td>
Run a native executable in the host OS
</td></tr>
</table>

<p/><h3>Utilities</h3>

The following commands are useful utilities:

<table border="1" cellpadding="5">
<tr><td>javap()</td><td>
Print the methods and fields of an object, similar to the output of javap
</td></tr>
<tr><td>which()</td><td>
Like the Unix 'which' command for executables.  Map the classpath and 
determine the location of the specified class.
</td></tr>
<tr><td>load(), save()</td><td> load a serializable object from a file
or save one to a file.  Special handling is provided for certain objects.
</td></tr>
<tr><td>object()</td><td>
Create an "empty" object context to hold variables; analogous to a Map.
</td></tr>
</table>

<p/><h3>Variables and Scope</h3>

The following commands affect the current scope:

<table border="1" cellpadding="5">
<tr><td>clear()</td><td>Clear all variables, methods and imports from
the current scope.
</td></tr>
<tr><td>unset()</td><td>Remove a variable from the current scope.
(Return it to the "undefined" state).
</td></tr>
<tr><td>setNameSpace()</td><td>
Set the current namespace to a specified scope.  Effectively bind the 
current scope to a new parent scope.
</td></tr>
</table>

<p/><h3>Classpath</h3>

The following commands manipulate or access the classpath:

<table border="1" cellpadding="5">
<tr><td>addClassPath(), setClassPath(), getClassPath()</td><td>
Modify the BeanShell classpath.
</td></tr>
<tr><td>reloadClasses()</td><td>
Reload a class or group of classes.
</td></tr>
<tr><td>getClass()</td><td>
Load a class explicitly taking into account the BeanShell classpath.
</td></tr>
<tr><td>getResource()</td><td>
Get a resource from the classpath.
</td></tr>
</table>

<p/><h3>Files and Directories</h3>

The following commands work with files, directories, and the working
directory:

<table border="1" cellpadding="5">
<tr><td>cd(), pwd(), dir(), rm(), mv(), cat()</td><td>
Unix Style file commands.
</td></tr>
<tr><td>pathToFile()</td><td>
Translate a relative path to an absolute path taking into account
the BeanShell current working directory.
</td></tr>
</table>

<p/><h3>Desktop and Class Browser</h3>

The following commands work with GUI tools:

<table border="1" cellpadding="5">
<tr><td>classBrowser(), browseClass()</td><td>
Open a class browser window or browse a specific class or object.
</td></tr>
<tr><td>desktop()</td><td>
Launch the BeanShell GUI desktop.
</td></tr>
<tr><td>setNameCompletion()</td><td>
Turn on or off name completion in the GUI console.
</td></tr>
</table>
<p/>
<br/>
<p/>

<note>
The dir() command is written in Java; primarily as a demonstration of how
to do this when desired.
</note>


</section>

