Can I do this, and if so, how?
Until Java SE 7, JDKs shipped with a JavaScript scripting engine based on Mozilla Rhino. Java SE 8 will instead ship with a new engine called Oracle Nashorn, which is based on JSR 292 and invokedynamic .
As of version 1.7R11 (May 2019), Rhino supports Java 8 and up, and supports a number of ECMAScript ES6/ES2015 features.
var window = {}
var document = {}
... of course, they won't do a lot of good unless you populate them with the properties that the script is trying to access.
You can't just populate them with the standard browser APIs - most of them don't make sense outside the context of the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With