Not quite sure about your needs, however, perhaps Rhino might work for you.
The JavaScript compiler translates the JavaScript Source into the Java files class. The resulting Java class files can be loaded and executed another time, providing a convenient method for transmitting JavaScript and to avoid the cost of translation.
Read more about the compilation function here .
source
share