Skip to content
Volker Berlin edited this page Apr 3, 2022 · 5 revisions

Q: Can I compile with JWebAssembly Swing, AWT or Applet applications?
A: No, you need to write a GUI via the DOM API from the JWebAssembly API project. In theory, anyone can write a library that implements support for Swing and / or AWT. However, but this is not recommended.

Q: How fast is the generated JWebAssembly code?
A: It is slower than if you compiled and run the same code with Java. WebAssembly does not currently have a JIT and JWebAssembly optimizations are small. In the first tests, the code was about 50% slower. However, this is not linear and has a large variance.

Q: Why should I use JWebAssembly?
A: In the end, you can only answer this yourself. Here are a few points:

  • It is open source.
  • WebAssembly will be an important technology in the future.
  • You are already familiar with Java.
  • With a source map you can debug your Java code in the browser.
  • You can run JUnit tests and debug it in your IDE (hopefully) in the future.

Q: Can I use the JWebAssembly output outside of the browser?
A: Yes, you can use it with Node.js. Theoretical it is also possible to use it with a WebAssembly runtime environment with WASI and without JavaScript support. But there are some conditions.

  1. For a small wasm file and a high performance the JWebAssmebly use the Garbage Collector (GC) of the WASM runtime. This required that the WebAssembly runtime supports the optional GC feature. Without the GC feature you can only use static Java code without any allocation.
  2. It required that someone write a library for WASI access. Currently there is only a library for JavaScript and DOM access. But this should be possible in some days and you can do it step by step.
Clone this wiki locally