Java 6 (and newer) has this in the standard library: see the javax.script package API documentation. You can use this to run scripts from your Java program (for example, to automate your program) using any scripting language for which the plug-in mechanism is available for the javax.script API. JavaScript is provided by default.
See the Java Scripting Programmer's Guide .
A simple example from this guide:
import javax.script.*; public class EvalScript { public static void main(String[] args) throws Exception {
source share