
So... what cool things can be done you ask? Patience grasshopper. Let's first get it installed. It'd be great if you'd review the "Getting Started" section of the bsh manual, but in a nutshell:
Grab the latest bsh jar which is currently 2.0b4. Either drop the BeanShell JAR file into your Java extensions folder or add it to your classpath:
Install as an extension. Place the bsh.jar file in your
$JAVA_HOME/jre/lib/ext folder
Or add BeanShell to your classpath like this:
nix: export CLASSPATH=$CLASSPATH:bsh-xx.jar
windows: set classpath %classpath%;bsh-xx.jar
You can then run BeanShell in either a GUI or command line mode:
java bsh.Console // run the GUI
or
java bsh.Interpreter // run as text-only on the command line
or
java bsh.Interpreter filename [ args ] // run a script file
It's also possible to call bsh from within native Java applications, to reach it in a remote server mode for debugging (very cool), to use it as a servlet, or even in an applet.
I'm a hacker at heart so one of the first things that I did was to fire up the class browser (in the workshop, type classBrowser(); ) and started explorer classes in my classpath. This simple tool has helped me understand APIs and undocumented methods for many classes. Just select a package and then class and the browser will reveal the constructor(s), method(s), and field(s). Plus you can see the file system path of the class which has helped me several times when I had classes loaded multiple times.
There's much more to talk about but this entry is getting long. Next time, I'll discuss more Console commands and some bsh examples. In the mean time, download bsh and read thru the manual. I think you'll agree - BeanShell has so much potential.
No comments:
Post a Comment