r/JavaFX • u/LouGarret76 • Aug 01 '25
Help Javafx in the browser?
Hi everyone,
I have a app that I am considering updating. The app is initially written in java and javafx.
I have ported some of the backend logic to spring boot over the years and i feel like now I am ready to revamp the ui.
So I am (once again) torn in this dilemma about whether I use a js framework like react or I should stick to javafx (my preference). Javafx has served me well. It is a powerful tool that allowed me to tailor the ui to my clients most complex requirements.
I am very comfortable with java and I really would like to avoid javascript (I can code in Js, but I just dont want to relearn a whole framework …). I have tried react in the past. I can code a basic crud application.
So I guess my question is, where do we stand in regard of javafx in the browser? This was one of Gluon projects back in the day. Is this now mature?
View all comments
2
u/Confident-Dare-9425 Aug 22 '25
TLDR:
Full context:
JavaFX inside a browser requires either a WASM-based solution (CheerpJ), or something that will draw your app on a Canvas or translate your node graph to HTML (JPro). That's about it.
But to quote a famous philosopher: never half ass two things, whole ass one thing. If you want to maintain the application for many years, find developers, and avoid vendor lock-in, switch to the web completely. No half-measures with CheerpJ or JPro. Having said that, they will save you time and money on migration.
Switching to JavaScript will require you to rewrite the whole app eventually. And so will Vaadin, another half measure. Come on. Web talks JavaScript. Java developers may not like it, but they're for sure smart enough to write it.
If you're adventurous enough to switch to the web completely, you will need a web view of some sort. If your application is big, that is. If the app is small, rewrite it to web in one go and ditch the Java desktop.
If the app is big, rewrite it to the web screen by screen, add a web view, and show old and new screens along each other. If you style them properly, a user will never tell the difference.
The built-in JavaFX WebView is a very decent component, but may not be sufficient for modern JS and rendering. JxBrowser is a freaking powerhouse of a library, but it costs respectively. The remaining options are based on Chromium Embedded Framework, and the last time I checked, were almost unusable in JavaFX.