I'm developing a JavaFX application that is mostly a glorified web page. It's a desktop application (it's no embedded into a web page) and it has a Web View for the main UI. The application itself serves the sole purpose of accessing Bluetooth devices using Bluecove because that's not possible directly with JavaScript on a web browser.
The proof of concept works ok (I was able to call JavaScript code from Java and vice-versa) but I have one extra requirement of calling arbitrary web services/API from within JavaScript but this violates the same origin policy (similar to this on Android: Allow remote ajax calls in an Android Webview + jquery mobile). Is this possible on JavaFX? Any tips?
P.S.: I'm using JavaFX 2.2.
Basically, javaFx has the issue which is coupled with CORS - https://javafx-jira.kenai.com/browse/RT-35868. Assuming that web services which you are using, have CORS enabled you can try the following approach:
System.setProperty("sun.net.http.allowRestrictedHeaders", "true")
OR
java -Dsun.net.http.allowRestrictedHeaders=true <your main class here>
Hope it will help you
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