X

Sundararajan's Weblog

  • Java
    August 21, 2006

Script engines written in JavaScript

Guest Author

JDK 6 contains javax.script (JSR-223) API and a Rhino based sample JavaScript engine. http://scripting.dev.java.net
project has been created to develop JSR-223 engines for other languages and useful, demo applications that use scripting.

Just added two more script engines to http://scripting.dev.java.net.
Unlike other script engines, this script engine is implemented in JavaScript. These engines implement JSP/ASP/PHP-like templating for JavaScript.

  1. ejs - embedded JavaScript - implements <%= expr %>, <% code %>
  2. jst - JavaScript Templates - this is based on TrimPath's JavaScript Templates.

It should be possible to use these script engines in Java code as well - because these implement javax.script API as required. But, you have to create a JavaScript engine and eval the corresponding scripts. And then call ejsScriptEngineFactory or jstScriptEngineFactory function to create javax.script.ScriptEngineFactory
for these engines.

It should be possible to use the jst and ejs engines with Phobos web application framework. [though I am yet to test that part!]

I came across these other language implementations on JavaScript:


  1. href="http://lambda-the-ultimate.org/node/1432">Oberon Script. A lightweight Compiler and Runtime System for the Web
  2. Scheme Implementation in JavaScript

Also, it seems that JavaScript 2
would be implemented as a translater that translates js2 to js1 (atleast to startwith).

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.