I'm looking for a standard Java to Java bytecode compiler implemented in JavaScript.
Has anyone heard of anything that can accomplish this?
The source code is passed through a program called a compiler, which translates it into bytecode that the machine understands and can execute. In contrast, JavaScript has no compilation step. Instead, an interpreter in the browser reads over the JavaScript code, interprets each line, and runs it.
The bytecode is a format that simplifies the execution of the JavaScript code by an interpreter, and then by the Just-In-Time compilers (JITs). The bytecode is much larger than the source code, so Firefox only generates the bytecode of executed functions.
An example of bytecodeWhen an application is written in Java, the Java compiler converts the source code to bytecode, outputting the bytecode to a CLASS file. The CLASS file is then read and processed by a Java virtual machine (JVM) running on a target system.
There are several here: https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS
Such as j2js, bicavm, doppio...(see the java section)
if your goal is to have users write Java in a browser and see it run, it makes.MUCH more sense to do the compiling and executing server side. A servlet could read the code, compile it and run it, then push the output back to the browser.
unless your thesis is "Anything that can be written in JavaScript will eventually be written in JavaScript."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With