Search the net for the Java scripting API. Also take a look at the classes and interfaces in the javax.script package.

I've never used this stuff, so I can't advise further.

db