Nikolas Papirniy
Nikolas Papirniy

Reputation: 353

JavaScript jvm implementation

Is there any JavaScript jvm implementations?
If no, can you give me some reasons why it hasn't realized already? (not possible probably?) I'm trying to understand what is absent to create one?

Reason why i'm asking is that i want to create web browser ide with compile functionality without even having jdk or jre installed on the computer(just in browser).

Upvotes: 21

Views: 8878

Answers (7)

neoexpert
neoexpert

Reputation: 468

There is an JVM written in Java which has an JavaScript Bytecode Interpreter: https://gitlab.com/neoexpert/jvm

It can also compile Bytecode directly to JavaScript to improve performance.

Upvotes: 0

KWallace
KWallace

Reputation: 1700

Very late answer, but for future inquirers: There is a new Java JVM implementation for JavaScript that has been released since this question was first asked. It claims to implement a JVM even without Java installed.

https://www.javapoly.com/

Upvotes: 1

Janus Troelsen
Janus Troelsen

Reputation: 21298

Most current one seems to be Doppio

Upvotes: 18

Steve Oh
Steve Oh

Reputation: 1159

You may have a look at the bck2brwsr (aka java.net HTML)

  • it is a VM that transforms java byte code into JavaScript (Bck2Brwsr Virtual Machine)
  • provides a Java based wrapper to HTML (HTML via Java APIs)

The scope of the project is not to execute any existing java library. (see http://wiki.apidesign.org/wiki/Bck2Brwsr)

There are two nice examples on the web:

  • a calculator, that gives good technical insight (http://xelfi.cz/bck2brwsr/)
  • a nice space invader demo as a proof of concept (JAYDAY 2013 java summit page)

To get started with a working example (needs Maven and JDK7):

Step 1: load archetype

mvn archetype:generate -DarchetypeGroupId=org.apidesign.bck2brwsr \
 -DarchetypeArtifactId=bck2brwsr-archetype-html-sample -DarchetypeVersion=0.7.2 \
 -DarchetypeRepository=https://maven.java.net/content/repositories/releases/

Step 2: build HTML page and dependencies and pack as ZIP file

mvn install
# produces bck-1.0-SNAPSHOT-bck2brwsr.zip

Step 3: unpack ZIP

cd target; unzip bck-1.0-SNAPSHOT-bck2brwsr.zip
  creating: public_html/
  creating: public_html/lib/
  extracting: public_html/lib/emul-0.7.2-rt.jar  
  extracting: public_html/lib/javaquery.api-0.7.2.jar  
  inflating: public_html/bck2brwsr.js  
  extracting: public_html/bck-1.0-SNAPSHOT.jar  
  inflating: public_html/index.html 

Step 4: open index.html with your browser

Upvotes: 7

Sanjay T. Sharma
Sanjay T. Sharma

Reputation: 23238

Not sure how mature jsJVM is but looks like something which you would be interested in. As the page says, it's JVM written in Javascript.

Upvotes: 6

user573215
user573215

Reputation: 4697

  1. +script seems to be interesting, too and the author also works on an web based IDE.

  2. BicaVM may be another option.

  3. The Orto project may be dead.

Upvotes: 3

Andrew Thompson
Andrew Thompson

Reputation: 168845

One of the problems of compiling Java using JavaScript is that the compiler typically needs to know the existence (or not) of the methods and attributes of a target Java minimum version. To even know that information, you would need to store properties, or variables that describe the public members of every single of class of the target J2SE. That represents a very big chunk of information.

Upvotes: 0

Related Questions