How to embed Angular 2+ app into JavaFX WebView as a GUI only?
03:30 21 Jun 2018

I am developing a simple Java client application, and I want to use HTML and a web application framework for its GUI instead of using Swing or JavaFX.

So I am designing, building and testing my entire application with Angular 6 (generated with angular-cli), and I'd like to use the JavaFX WebView and WebEngine components to point to my Angular UI.

Is there any easy/out-of-the-box/best-practice way to wire everything up?

I'd like the user just starting the application and not even realizing he's browsing something webby. If possible, I wouldn't even start any web server. I just want a self-contained application and using angular framework for GUI purpose only.

If I had to start a web server, I'd like to do so behind the scenes and don't want the user to realize.

Problems

  • I tried to just make the WebEngine point to the built angular app, but this does not work out-of-the-box with Angular-cli;
  • I tried to use com.sun.net.httpserver but all the explanations on the web only say how to implement your own dummy HttpHandler, so I was not able to understand how to bind the server to my actual built web application (which lies in a folder in my project path) or how to deploy my web application into the HttpServer, whichever is correct.
java angular javafx webview angular-cli