January 01, 2010

Beanshell Example

« Java Swing Example | Main | Mysql New User »

Beanshell represents a dynamic script language for the Java VM. The Java scripting language support is useful for dynamic aspects of your software. For example the developer would have a possibility to change or affect the software runtime behaviour.

The following example describes how to embed and execute beanshell scripts inside of your software:

Interpreter interpreter = new Interpreter();
interpreter.set("startTime", new Date());

String script = 
    "multiply( x, y ) {" +
    "  return x * y;"+
    "}" +
    "multiplyResult = multiply(2, 2);" +
    "print(multiplyResult);" +
    "print(startTime)";

interpreter.eval(script);

Regards
Rafael Sobek

Technorati Tags:

Posted by rafael.sobek at 2:39 PM in Java

 

[Trackback URL for this entry]

Pingback: Beanshell Example « Drakz Programming News Station at Sa, 2 Jan 8:47 AM

Beanshell Example
Languages , Technologies and Visions. Topics: Visions, Architecture Issues, Programming Languages , … Search: January 01, 2010 Go here to read the rest: Beanshell Example Tags:

Your comment:

(not displayed)
 
 
 

Live Comment Preview:

 
 
test