J2CL plugin question

37 views
Skip to first unread message

Tim Macpherson

unread,
Dec 27, 2025, 1:08:38 PM (yesterday) Dec 27
to GWT Users
Can someone advise if it's the best tool for building js code from pure logic front end java ? I need to enable usage for those not using GWT. Thanks

Colin Alworth

unread,
Dec 27, 2025, 2:17:29 PM (yesterday) Dec 27
to GWT Users
"Best" is hard to define - what are your requirements?

If GWT doesn't fit your use cases, it seems unlikely that J2CL will - can you elaborate on what about GWT doesn't work for you? If anything, I've found J2CL to be more picky than GWT in just about every way - more limited options for emulation, more requirements for JsInterop, no JSNI/Generators, smaller ecosystem and prior art for customizing the build (whether using the maven plugin or the official Bazel build tooling).

It does tend to produce slightly smaller and slightly faster output, and does offer better integration with compiling plain JS sources in the same build (with the requirement that this JS must be built to be safe to compile by closure-compiler in ADVANCED mode).

For a generally bigger set of JRE emulation (and much larger output sizes), consider TeaVM or CheerpJ - both have their strengths. I don't have a lot of experience with either, but I do find that for math-heavy apps, TeaVM does a great job getting even better performance in some cases than GWT or J2CL, and produces output much more quickly. It tends to do much more poorly on string heavy (e.g. DOM manipulation). CheerpJ I have almost no experience with, but excels at supporting nearly any JRE-compatible code, and finding a way to make it work regardless of whether the browser is a good place to run it. This is a huge advantage for "it doesn't matter as long as it can run" cases - more and more it can be possible to run a JS app that is hundreds of times what would have been acceptable a few years ago.

Tim Macpherson

unread,
Dec 27, 2025, 2:34:46 PM (24 hours ago) Dec 27
to google-we...@googlegroups.com
GWT works for me and I will always be using it in my own stack while it's maintained, but I need to make some of my d3 js code and client java surrounding it available for others who don't use GWT. Teavm is maybe best tool for that.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-web-toolkit/12612394-a3db-4171-b11d-2b2dea7706c7n%40googlegroups.com.

Colin Alworth

unread,
Dec 27, 2025, 3:58:58 PM (22 hours ago) Dec 27
to GWT Users
It still isnt quite clear to me what you're asking for - can you be more precise?

That is, if you're writing d3 js code, the best way to make that available to others is JS. Each Java-to-JS compiler first assumes that the next developer is using Java, but each makes their own assumptions about how to map JS ideas to Java, so there isn't a one-size-fits-all approach. JsInterop types at least are mostly the same for both J2CL and GWT - but if you have a user who doesn't use GWT, they probably also don't use Java in the client at all?

Tim Macpherson

unread,
Dec 27, 2025, 4:33:42 PM (22 hours ago) Dec 27
to google-we...@googlegroups.com
I want to provide client js that is logic only, no UI,  I write it in  java because the tooling in typescript is not good enough. I need to release this as pure js, it's that simple
On Sat, Dec 27, 2025 at 8:59 PM, Colin Alworth
It still isnt quite clear to me what you're asking for - can you be more precise?

That is, if you're writing d3 js code, the best way to make that available to others is JS. Each Java-to-JS compiler first assumes that the next developer is using Java, but each makes their own assumptions about how to map JS ideas to Java, so there isn't a one-size-fits-all approach. JsInterop types at least are mostly the same for both J2CL and GWT - but if you have a user who doesn't use GWT, they probably also don't use Java in the client at all?

On Saturday, December 27, 2025 at 1:34:46 PM UTC-6 tim_mac...@yahoo.co.uk wrote:
GWT works for me and I will always be using it in my own stack while it's maintained, but I need to make some of my d3 js code and client java surrounding it available for others who don't use GWT. Teavm is maybe best tool for that.


On Sat, Dec 27, 2025 at 7:17 PM, Colin Alworth
"Best" is hard to define - what are your requirements?

If GWT doesn't fit your use cases, it seems unlikely that J2CL will - can you elaborate on what about GWT doesn't work for you? If anything, I've found J2CL to be more picky than GWT in just about every way - more limited options for emulation, more requirements for JsInterop, no JSNI/Generators, smaller ecosystem and prior art for customizing the build (whether using the maven plugin or the official Bazel build tooling).

It does tend to produce slightly smaller and slightly faster output, and does offer better integration with compiling plain JS sources in the same build (with the requirement that this JS must be built to be safe to compile by closure-compiler in ADVANCED mode).

For a generally bigger set of JRE emulation (and much larger output sizes), consider TeaVM or CheerpJ - both have their strengths. I don't have a lot of experience with either, but I do find that for math-heavy apps, TeaVM does a great job getting even better performance in some cases than GWT or J2CL, and produces output much more quickly. It tends to do much more poorly on string heavy (e.g. DOM manipulation). CheerpJ I have almost no experience with, but excels at supporting nearly any JRE-compatible code, and finding a way to make it work regardless of whether the browser is a good place to run it. This is a huge advantage for "it doesn't matter as long as it can run" cases - more and more it can be possible to run a JS app that is hundreds of times what would have been acceptable a few years ago.

On Saturday, December 27, 2025 at 12:08:38 PM UTC-6 tim_mac...@yahoo.co.uk wrote:
Can someone advise if it's the best tool for building js code from pure logic front end java ? I need to enable usage for those not using GWT. Thanks

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion visit

Craig Mitchell

unread,
Dec 27, 2025, 4:55:42 PM (21 hours ago) Dec 27
to GWT Users
Isn't that what <packaging>gwt-lib</packagingis designed for in GWT? ( https://tbroyer.github.io/gwt-maven-plugin/usage.html )

Unless you're not running on a Java backend.  So you'd need a npm package created somehow.  Not sure how to do that.

Dmitrii Tikhomirov

unread,
Dec 27, 2025, 11:59:46 PM (14 hours ago) Dec 27
to google-we...@googlegroups.com

I am the person who continues to maintain the J2CL Maven plugin. If you need to build a JavaScript application and run it in a JavaScript environment, you can look at how this is implemented here (https://github.com/apache/incubator-kie-tools/tree/main/packages/serverless-workflow-diagram-editor) (this is an application that uses a Jakarta-like CDI framework, along with JSON/YAML marshallers).

It looks like the Google team is finishing work on adding support for records, so I will be updating the entire stack soon to enable these features

At the moment, GWT is noticeably more stable than J2CL, so I would recommend taking another look at it. However, if you really do not want to go that route, you could also consider running a WASM application using GraalVM.


Tim Macpherson

unread,
10:14 AM (4 hours ago) 10:14 AM
to google-we...@googlegroups.com
Thanks for your responses, GraalVM WASM is something to keep in mind but easiest to use teavm for now, basic plumbing is straightforward. Unfortunately Craig afaik to generate js from a GWT lib it has to be compiled in a GWT app.
Reply all
Reply to author
Forward
0 new messages