-1

When I am running Javascript in a browser I have the document object available to me.

For instance, I can do document.write() in javascript in a browser.

The document object is not available when I am running Javascript under the Java 8 Javascript engine jjs.

jjs is a the successor to Rhino and is delivered with Java 8 from Oracle.

What objects are available in jjs? Where are they documented?

Karl-Johan Sjögren
  • 16,544
  • 7
  • 59
  • 68
Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125
  • google "javascript jjs" and you get https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jjs.html – Rhumborl Jan 24 '16 at 16:41
  • Those are command line arguments. I am looking for the objects that I can use in the javascript. I will clarify my question a bit more. – Be Kind To New Users Jan 24 '16 at 16:50
  • It would be appreciated if those who are voting to close would state their reason. Then I might know how to reword the question. – Be Kind To New Users Jan 24 '16 at 16:54
  • Other than the standard JavaScript built-ins, there's really *nothing* available by default in the global scope. You can, however, create a global environment of your own design inside your Java code by explicitly exposing APIs through the `ScriptEngine` mechanism. – Pointy Jan 24 '16 at 17:00
  • Also the "close" votes are based on the fact that this appears to be a request for documentation, and that's an established reason for questions to be closed. – Pointy Jan 24 '16 at 17:02

1 Answers1

2

The document won't be available when running via Nashorn/jjs since it doesn't have a DOM (like a javascript engine in a browser would), the same goes for window. In other aspects it should implement ECMASCRIPT 5.1 but according to this blog post from Oracle it also lacks the console object which is a shame.

I haven't seen to much documentation about other stuff missing from the engine but there are a few pages which might be worth looking into over at the OpenJDK Wiki for Nashorn.

Karl-Johan Sjögren
  • 16,544
  • 7
  • 59
  • 68
  • Thank you, this was what I was looking for: https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions I will give you the win before they close this question. – Be Kind To New Users Jan 24 '16 at 17:08