Fighting with computers

Computers are not always friendly.

Wednesday, November 03, 2010

Java and Javastript playing together

One of the features that came with Java 6 is this neat trick: You can have a Javascript runtime on your Java program. You feed it with Javascript code and you can get the value of the variables.

It looks great if you need to use some logic already encoded with Javascript and you need to include it in your Java program. No rewriting is needed then.

I've done a sample program to evalaute a simple arithmetic expression as the first command line parameter of this Java program.


Post a Comment

<< Home