Listing All Environment Variables ...With Java 8 And JavaScript

With Java 8 you can use JavaScript / Nashorn instead of bash / zsh syntax for shell scripting:


#!/usr/bin/jjs -fv
for (entry in $ENV) {
    print(entry + "->" + $ENV[entry]);
}

JavaScript shell scripting is particularly interesting for automation and system testing.

See you at Java EE Workshops at MUC Airport or on demand and in a location very near you: airhacks.io!

Comments:

Interesting, this fails on Windows with a ReferenceError: "$ENV" is not defined

Posted by Andy on March 06, 2014 at 09:20 AM CET #

launch jjs with "jjs -scripting"
instead of simply "jjs"

and $ENV will be accessible on wincows

Posted by Olivier on April 03, 2014 at 06:43 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License