How to compile Java to WASM (WebAssembly)?

Here are a few compilers that can do this for you:

https://github.com/konsoletyper/teavm (most popular & my own reccomendation: https://teavm.org/)

https://github.com/i-net-software/JWebAssembly (only to webassembly, the others can do webassembly and javascript)

https://github.com/mirkosertic/Bytecoder

https://github.com/leaningtech/cheerpj-meta

Do note, that all of them have their limitations, most commonly that every Java class in Java’s standard library won’t work well with it (for example, TeaVM and others have problems with reflection).

They also require pipeline integration — make sure to be using a build tool these compilers support, such as gradle or maven

Leave a Comment

tech