Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8091505

Add Nashorn API to a WebView

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 7u45
    • javafx
    • Window 8, JDK 8 b116.

    • web

      At the moment Nashorn API (http://download.java.net/jdk8/docs/technotes/guides/scripting/nashorn/api.html) is not available in a WebView. A try to run this:

          System.out.println(browser.getEngine().executeScript("Java.type(\"java.lang.Math\").PI"));


      Would lead to JSException:

      netscape.javascript.JSException: ReferenceError: Can't find variable: Java
      at com.sun.webkit.dom.JSObject.fwkMakeException(JSObject.java:128)
      at com.sun.webkit.WebPage.twkExecuteScript(Native Method)
      at com.sun.webkit.WebPage.executeScript(WebPage.java:1410)
      at javafx.scene.web.WebEngine.executeScript(WebEngine.java:934)

      Adding Nashorn API would simplify running Java code in a WebView and make easier the development of desktop applications using JavaScript frameworks like AngularJS, Twitter Bootstrap, PhoneGap, etc. Though it is possible at the moment, it requires adding boilerplate code and JavaScript-to-Java call workarounds, i.e. serializing complex objects to JSON.

            Unassigned Unassigned
            achaschevjfx Andrey Chaschev (Inactive)
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: