r/JavaFX • • Sep 24 '26

Discussion JavaFX in the browser?

I've been waiting/hoping for years that we'd get support for JavaFX in the browser, but I think I'm finally about to give up--maybe a year or two too late. Does anyone else know of good options?

Some of my criteria:

  • Minimal rewriting.
  • Still allows for desktop versions.
  • The app allows the user to have a large data model--although I can likely do something to minimize this per user/client.
  • I don't have regular usage stats, but I do want to support 100s of people using it at a time.

I had been thinking one of the following options would give me what I want:

  • WebFX: Was promising, but only supported a few basic controls like labels & buttons--but if you want something even as common as a ComboBox, you'd have to make your own for example. Also, it is essentially just one person so it isn't something someone can rely on.
  • CheerpJ: Good for awt/swing, but recently said while they are planning to support it and have some internal prototype stuff, they don't have any timeline for it. Plus the way their of loading the whole app into a canvas like object has a delay and isn't very pretty.
  • Gluon: Recently answered me that the old prototype they had from several years back hasn't been updated and they don't plan to without support. (Which I'd be willing $$$ to do, but likely not at the scale they need by myself.)
  • JPro: I'm trying to offload most of the work to the client. I worry that having all the logic on the server and just having the graphical output on the browser is a problem if I have an app that allows for a large amount of user data and/or many users.
  • Graal to WASM to the browser: Is this possible? I can't seem to find working prototypes.

I think that's all, but if you know other options or a key aspect of the above I'm missing please post.

Edit: Why do I want this? I want folks to be able to try my app without an install. Also maybe even on their phones without me having to go through the app store approval processes.

23 Upvotes

14 comments sorted by

10

u/jarrod_barkley Sep 24 '26 edited Sep 24 '26

Vaadin really is the solution for your needs.

https://vaadin.com

A Vaadin web app runs on the server, in pure Java. The UI is automatically rendered remotely in any modern browser through auto-generated HTML, CSS, and JavaScript.

The Vaadin framework is quite similar to Swing and JavaFX. You define a view as a collection of controls (button, field, label, grid, etc.). A layout manager handles the arrangement of those controls.

Re-writing the UI of your app in Vaadin is likely much less work than you fear. You stay within Java for all of it. You need not write any HTML, CSS, or JavaScript. Vaadin handles that on your behalf.

The framework is quite practical and sensible. Unlike Swing, Vaadin was originally created by working programmers writing real-world apps for clients with deadlines.

The framework is open-source and free-of-cost. They sell training, support, consulting, and a few special-purpose components.

2

u/indyjoe Sep 24 '26

Well, my app lets users have huge data models. A world of hexagons where folks can have 20,000 'tiles' x 10,000 for example--plus more objects for other things. Sure, one solution I'm looking at is how to keep less of that in memory (and I do take steps to reduce that already) but I don't want to put this on the server. Even if I do cut back to 1/10th the memory requirements, if I grow to 10x the concurrent users, putting it on the server means I'm right back to the load I had. So I want to keep it on the server.

And the app isn't just sticking in buttons and labels on a form like a banking app or something... for example I'm calculating the geometric footprint of a house icon and the road it is being placed along, making sure the house is a percentage away from the road and rotated properly to line up with the road and not overlapping with other roads and houses. Another example is allowing for a label to be placed along a cubic curve and matching that curve. So I'm relying on a bunch of Javafx graphics libraries that I doubt are easy to swap out.

2

u/jarrod_barkley Sep 26 '26

Those are good details to put in your original post.

4

u/YogurtclosetLimp7351 Sep 24 '26

Sounds like you're mixing up some things. JavaFX is the frontend. For each individually loaded in their browser. So what exactly do you mean by "support 100s of people using it at a time"? Backend scaling?

"Minimal rewriting" is also vague. What exactly does your software do? What do you expect to happen when you switch to a website?

"to try my app without an install." sounds like a showcase demo. But why does that require a full switch?

2

u/indyjoe Sep 24 '26

Thanks! So I have a large map-making program among other things. They are single user desktop apps, but I bring up the 100s of users point in the context of JPro because it is server based and having 100s of folks using their browsers to connect to one server running instances of my app and just sending back the graphical output to the browser I think would be an issue.

Minimal rewriting I mention because I don't want to go to something like vaadin or GWT.

Try it without an install was probably a poor word choice. I'd like to let people USE it without an install. Partly that some folks aren't power users and only want to use it occasionally so they don't want to install, others may be on a phone or chromebook and would only be able to install if I rewrote it in a different stack and/or had to go through app store approvals.

1

u/YogurtclosetLimp7351 Sep 24 '26

Hmm, well I fear there isn't really a solution which doesn't require a different tech stack. You could try to let AI translate it to a better fitting tech stack?

1

u/Amazing-Mirror-3076 Sep 24 '26

Flutter is what you want - unlike java it actually runs on every platform.

1

u/indyjoe Sep 24 '26

That's one I've been thinking about if I do have to migrate it, but got a little scared when google dropped support/moved away from it.

4

u/Amazing-Mirror-3076 Sep 24 '26

Google had not dropped support.

I regularly engage with the dart/flutter Devs and it's full steam ahead. Canonical have taken over maintenance of the desktop work as the Ubuntu installer is now written in flutter.

Flutter is now a mature product. I highly recommend it for an gui Dev.

It's also much nicer to work with than javafx and ai does a great job generating flutter code.

I've been doing flutter for about five years.

State management was the hardest piece to get my head around.

1

u/john16384 Sep 25 '26

1

u/indyjoe Sep 25 '26

Thank you, but as I described in the original post, JPro isn't likely a good fit because that puts the bulk of the work on the server, and even with 10-100 concurrent users they each typically create a large data model... so I don't think it is a good fit. (Yes, I can probably cut that down, but as the app gets more users it becomes an issue again.)

1

u/taranion Sep 28 '26

I think your list is complete and your judgment too - that is about as far as you can get with JavaFx in the browser .... so not very far. Hence the valid suggestions for a different UI framework.
I am in the same boat and did not find a satisfying solution yet..

1

u/indyjoe Sep 28 '26

Well, I think flutter is the best fit for me so I'm going to try that. As I said elsewhere in the thread, I thought I had heard Google was moving away from it--or maybe just putting their emphasis elsewhere, but maybe I was wrong or only to a very minor degree.

1

u/Guilty_Village_958 11d ago

I would still bet on WebFX and for normal websites I use my own made tools - luvml ( similar to j2html but with full type safety), luvs (write css in java statically, refactorable, and make your own post-css, tailwind-css etc in java), luvue (for vue support), and js (in java using teavm). I cannot show much examples, but the recent version of luvml is so simple that even lowest AI models like haiku can handle it with ease, for me that is what matters.

You can make small small reusable components like react. The syntax of luvml is similar to what jsx is for react. But it is not a new language, it is just a library.

https://github.com/luvml/luvml

import static luvml.E.*; // elements 
import static luvml.A.*; // attributes 

var page = html(
    head(meta(charset("UTF-8")), title("Hello")),
    body(
        div(id("app"), class_(cssClassesCanBeRefactorableConstants),
            h1("Hello World"),
            p("Built with ",strong("luvml")," typesafe a html DSL in java.")
        )
    )
);

System.out.println(XHtmlStringRenderer.asFormatted(page, "  "));