Java 9: Nashorn Scripting / Automation Improvement

Nashorn's $EXEC built-in function was extended to support Java's System.out and System.err as parameters:


#!/usr/bin/jjs -fv
var cmd = "mvn clean install"
var System = Java.type("java.lang.System");
$EXEC(cmd, System.in, System.out, System.err);

The code above executes Maven and "streams" the output in real time into the console. With Java 9 Nashorn is even more useful for cross-platform automation of OS-level tasks.

Docklands Dockerfiles come with Nashorn script: build.js.

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Comments:

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