./spin build
./spin up
./spin deploy
This is a example demonstrating how to use TeaVM-WASI, wit-bindgen, and Spin to build and run a simple stateless web service in Java, targetting WebAssembly
- A recent JDK (e.g. OpenJDK 18)
- Maven
- Spin 0.6.0
- cURL (or a web browser) for testing
On Ubuntu 22.04 x86_64, this should do the job:
sudo apt install openjdk-18-jdk maven curl
curl -L -O https://github.com/fermyon/spin/releases/download/v0.6.0/spin-v0.6.0-linux-amd64.tar.gz
tar xf spin-v0.6.0-linux-amd64.tar.gz
sudo cp spin /usr/local/bin/
spin build
spin up &
curl http://localhost:3000
- Rust
- A recent wit-bindgen (git commit 9609ca8 is known to work)
cargo install --git https://github.com/bytecodealliance/wit-bindgen \
--rev 9609ca8daf2dadcb71082a1ad7ec86bbf0fbb5ef --locked wit-bindgen-cli
wit-bindgen guest teavm-java --export wit/spin-http.wit \
--out-dir src/main/java/wit_spin_http/
wit-bindgen guest teavm-java --import wit/wasi-outbound-http.wit \
--out-dir src/main/java/wit_wasi_outbound_http/