Wednesday, September 03, 2003
BeanShell
BeanShell 2.0 beta 1 announcement
Beanshell is cool! It brings scripting to Java. There are plenty of scripping languages for Java, however, Beanshell follows the Java syntax pretty close, so it is a good prototype and test framework language.
Here is a simple example:
Create a java class file called HelloWorld.java:
class HelloWorld {
public static void main (String [] args) {
System.out.println("Hello World!");
}
}
Then at the command line (in Windows) do:
java -cp bsh-2.0b1.jar bsh.Interpreter HelloWorld.java
Now add to that same file another method,
class HelloWorld {
public static void speak(){
System.out.println("Hello World, from method!");
}
public static void main (String [] args) {
System.out.println("Hello World!");
}
}
And, create a new script file:
// CallHelloMethod.bsh
source("HelloWorld.java");
HelloWorld.speak();
Now, at the command line we get:
C:\downloads\javaDownloads\BeanShell>java -cp bsh-2.0b1.jar bsh.Interpreter HelloScript.bsh
Hello World, from method!
Now can Ant task extensions be written in the new Beanshell directly? Good competitor to Jelly, maybe.
References:
Beanshell
JVM Languages
BSF
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment