This is what you need to do:

public void go(Object objt, String Fname) throws EvalError {
    intp.set("objt", objt);
    intp.eval("obj." + Fname);

Daedalus <> wrote:

I'm new to beanshell so I don't know if this is possible but here goes.

I'm using java with an imported interpreter to evaluate a string which
contains the name of a method I want to exacute.

import bsh.EvalError;
import bsh.Interpreter;
Interpreter intp = new Interpreter();
public static void main(String[] args) throws EvalError {
Ex w = new Ex();


public void go(Object objt, String Fname) throws EvalError {

intp.eval(objt + intp.eval(Fname));

public void message() {

I have a go() method that is ment to take an object and string then the go()
method should evaluate the Fname to convert the string to a method and
combine it with my object and execute it.

so it would look like objt.message();

however the intepreter produces this error

at bsh.Interpreter.eval(Unknown Source)

Could someone point me in the right direction or tell me an alternative way
of doing this?

View this message in context:
Sent from the BeanShell - User forum at

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
Beanshell-users mailing list

2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500

Yahoo! Music Unlimited - Access over 1 million songs. Try it free.