Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the JRE be compiled to and run in Web Assembly?

Could the Java Runtime be compiled for the Web, given the ability to translate Java bytecode to WebAssembly, and run Java VM from the browser, not in an widely unsupported applet? I know there is a alternative that is both easier and faster than this (JWebAssembly), but this is more about the principle than the application. I am just curious if this could happen.

like image 606
0x1a4 Avatar asked Nov 05 '25 03:11

0x1a4


1 Answers

This question has some significant parallels with how you can run C# within the browser using WebAssembly. Both Java & C# run within their own virtual machine, the JRE and .Net CLR respectively.

In order to run C# within WebAssembly, the Blazor project took one of the open source CLR implementations and compiled it to WebAssembly. This allows C# DLLs to run within the browser.

Exactly the same solution could be used to run Java in the browser, however, a key to this would most likely be finding a suitable open source JRE implementation that can be compiled to WebAssembly.

like image 182
ColinE Avatar answered Nov 06 '25 20:11

ColinE