![]() Home | ![]() Back | ![]() Contents | ![]() Next |
exit() | Exit the interpreter. (Also Control-D). |
show() | Turn on "show" mode which prints the result of every evaluation that is not of void type. |
setAccessibility() | Turn on access to private and protected members of Java classes. |
server() | Launch the remote access mode, allowing remote access to the interpreter from a web browser or telnet client. |
debug() | Turns on debug mode. Note: this is very verbose, unstructured output and is primarily of interest to developers. |
setStrictJava() | Turn on "strict Java" mode which enforces Java compatability by dissallowing loose types and undeclared variables. |
print(), error() | 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. |
frame() | Display the AWT or Swing component in a Frame |
eval() | Evaluate a string as if it were typed in the current scope. |
source() | Source an external file into the current interpreter |
run(), bg() | Run an external file in a subordinate interpreter or in a background thread in a subordinate interpreter. |
exec() | Run a native executable in the host OS |
javap() | Print the methods and fields of an object, similar to the output of javap |
which() | Like the Unix 'which' command for executables. Map the classpath and determine the location of the specified class. |
load(), save() | load a serializable object from a file or save one to a file. Special handling is provided for certain objects. |
object() | Create an "emtpy" object context to hold variables; analagous to a Map. |
clear() | Clear all variables, methods and imports from the current scope. |
unset() | Remove a variable from the current scope. (Return it to the "undefined" state). |
setNameSpace() | Set the current namespace to a specified scope. Effectively bind the current scope to a new parent scope. |
addClassPath(), setClassPath(), getClassPath() | Modify the BeanShell classpath. |
reloadClasses() | Reload a class or group of classes. |
getClass() | Load a class explicitly taking into account the BeanShell classpath. |
getResource() | Get a resource from the classpath. |
cd(), pwd(), dir(), rm(), mv(), cat() | Unix Style file commands. |
pathToFile() | Translate a relative path to an absolute path taking into account the BeanShell current working directory. |
classBrowser(), browseClass() | Open a class browser window or browse a specific class or object. |
desktop() | Launch the BeanShell GUI desktop. |
setNameCompletion() | Turn on or off name completion in the GUI console. |
Note: The dir() command is written in Java; primarily as a demonstration of how to do this when desired. |
// File: helloworld.bsh helloworld() { print("Hello World!"); } |
// File: helloworld.bsh helloworld() { print("Hello World!"); } helloworld( String msg ) { print(msg); } |
// File: setvar.bsh fooSetter() { this.caller.foo=42; } |
fooSetter(); print( foo ); // 42 |
foo() { ... } foo(); |
foo() { bar() { ... } ... } // somewhere fooObject.bar(); |
eval("a=5"); print( a ); // 5 |
this.caller.caller...; |
assert( boolean condition ) { if ( condition ) print( "Test Passed..." ); else { print( "Test FAILED: " +"Line: "+ this.namespace.getInvocationLine() +" : "+this.namespace.getInvocationText() +" : while evaluating file: "+getSourceFileInfo() ); super.test_failed = true; } } |
javap( class ); // use a class type directly javap( someobject ); // uses class of object javap( "java.lang.Thread" ); // Uses string name of class javap( java.lang.Thread ); // Use plain class identifier |
if ( o instanceof Name.ClassIdentifier ) clas = this.namespace.identifierToClass(o); if ( o instanceof String) clas = this.namespace.getClass((String)o); else if ( o instanceof Class ) clas = o; else clas = o.getClass(); |
![]() Home | ![]() Back | ![]() Contents | ![]() Next |