A minimal Java application that embeds a WebAssembly module with GraalWasm.
Install GraalVM for JDK 23 and set the value of JAVA_HOME
accordingly.
We recommend using SDKMAN!. (For other download options, see GraalVM Downloads.)
sdk install java 23-graal
To build and test the demo, run:
./mvnw test
To execute the main method, run:
./mvnw exec:java
To build and test the demo, run:
./gradlew test
To execute the main method, run:
./gradlew run
The WebAssembly is stored in the resource file add-two.wasm
.
You can examine its textual representation in the resource file add-two.wat
.
If you want to experiment with and tweak the WebAssembly module, you will need to rebuild the add-two.wasm
file from the add-two.wat
file.
For that, you can use the wat2wasm
tool from the wabt toolkit.
You can also use this web app to run wat2wasm
in your browser instead of installing wabt
.