X

Sundararajan's Weblog

  • Java
    November 12, 2005

Configuration (Java)Scripts

Guest Author
Many Java applications use various configuration files. These are mostly of the form

With Mustang, JavaScript engine is part of JRE. With Mustang, Java programmers can make use of JavaScript files as "config" files. It is easy very easy to use ScriptEngine.eval method to parse the config file. The idea of using "scripting" language(s) for configuration is nothing new (for example, XEmacs uses Lisp)

For each "config parameter", you can define and initialize a script global variable in your script file. ScriptEngine.get method
can be used to get the config parameter value from Java. If you want to be able to use your config. file(s) by other systems/programs without access to JavaScript engine as well, then you may want to consider JSON - JavaScript Object Notation. Because JSON uses subset of JavaScript object literal syntax -- so you can continue to use JavaScript engine to parse config file(s) in your Java programs.

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.