简体   繁体   中英

How to generate .wasm file or .wast file from java source code?

How I can generate.wasm file or.wast file for the following code:

import java.util.ArrayList;
public class NewClass2
{
    public static void main(String[] args)
    {
        ArrayList<String> lis = new ArrayList<>();
        lis.add("My");
        lis.add("Name");
        System.out.println(lis.get(2));
    }
}

Can anyone help me in this regard? I have check TeaVM, CheerpJ, etc, but unable to find to get generate web assembly code.

While one could, in theory, write a compiler from JavaScript to WebAssembly, converting JavaScript to WebAssembly is not currently possible or something that WebAssembly was explicitly designed for. If you want to write code that looks somewhat like JavaScript, but targets WebAssembly, the closest thing today is probably AssemblyScript: https://www.assemblyscript.org/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM