tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java Scripting > BeanShell > Implementing Interfaces

Implementing Interfaces 

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell is a natural scripting language for Java. This requires the library bsh-2.0b4.jar to be in classpath. The following example shows implementing interfaces in beanshell script.

File Name  :  
/BEAN_SHELL001/config/implement_interface.bsh 
   
run1 = new Runnable() {
    run() {
      for (i = ; i < ; i ++) {
        print("My Thread : " + Thread.currentThread());
      }
    }
};

t = new Thread(run1);
t.start();
   

File Name  :  
com/bethecoder/tutorials/bean_shell/ImplementInterfaceTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.bean_shell;

import java.io.InputStreamReader;

import bsh.EvalError;
import bsh.Interpreter;

public class ImplementInterfaceTest {

  /**
   @param args
   @throws EvalError 
   */
  public static void main(String[] argsthrows EvalError {
    Interpreter interpreter = new Interpreter();  

    InputStreamReader reader = new InputStreamReader(
        ImplementInterfaceTest.class.getClassLoader()
        .getResourceAsStream("implement_interface.bsh"));
    interpreter.eval(reader);
  }

}
   

It gives the following output,
My Thread : Thread[Thread-0,5,main]
My Thread : Thread[Thread-0,5,main]
My Thread : Thread[Thread-0,5,main]
My Thread : Thread[Thread-0,5,main]



 
  


  
bl  br