I\'m following up on this answer:
I managed to run simple JavaScript
code from Rhino Engine on Java.
But when it comes to D3.js, for example:
JsDom might be a bad option since it relies on so many internal features of Node and Google's V8 JavaScript engine. Env.JS should be a better option but if it doesn't work then you're probably out of luck. It might not work because it's essentially a frozen project with last release in 2010. You'll have to either run your JavaScript in Node or Phantom, or generate SVG with Java-based solutions like Apache Batik.
By the way require
in JsDom is not the same as require.js
but a build-in Node.js function.
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