Compile Java to asm.js
asm.js (currently) is designed as a target for languages that manually manage memory allocation and release -- like C/C++. It cannot currently handle languages with garbage collection semantics, silly as that may seem given that it is JavaScript which is a garbage collected runtime.
If you really wanted to go the round way about, pass the Java code through j2c and then pass that C++ output through emscripten which will compile to asm.js.
Another possibility would be to pass the Java code through the LLVM compiler using the VMKit and pass that through the emscripten asm.js llvm backend...
As of 2020, you probably want to transpile to web assembly instead of asm.js. These tools are currently available:
- Bytecoder
- JWebAssembly (no garbage collection with current WASM implementation)
- TeaVM (support for WASM is experimental)