Basically I want to be able to do be able to parse a JavaScript-like syntax. For example:
var results = system.function('example');
if(results == "hello") {
console_print("ding dong.");
}
So basically you get it, results will be a “string” and system.function will call a Java method, and those results will go into the results string.
I want to be able to do basic math, and validation in this as well, but I want this done in Java. Any ideas?
If you’re willing to use JavaScript (not just JavaScript-like), and you’re using Java 1.6+, then you can use the Scripting API:
which will print:
to the console.
And to invoke Java methods from the scripting language, you could give BeanShell a try:
which will print:
The core interpreter JAR of BeanShell is only 143 KB: more lightweight than that will be difficult, IMO.