I\'m following up on this answer:
I managed to run simple JavaScript code from Rhino Engine on Java.
JavaScript
But when it comes to D3.js, for example:
Another approach would be using Domino as a DOM environment. Look here (http://jazdw.net/content/server-side-svg-generation-using-d3js) for details. Reading comments section would be also helpful