Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java bytecode compiler in JavaScript

I'm looking for a standard Java to Java bytecode compiler implemented in JavaScript.

Has anyone heard of anything that can accomplish this?

like image 413
Jivings Avatar asked Feb 17 '12 22:02

Jivings


People also ask

Does JavaScript compile to bytecode?

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.

What is byte code in JS?

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.

What is Java bytecode explain with an example?

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.


2 Answers

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)

like image 150
edtechdev Avatar answered Sep 20 '22 13:09

edtechdev


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."

like image 32
Thorn Avatar answered Sep 22 '22 13:09

Thorn