Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript jvm implementation

Tags:

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

like image 661
Nikolas Papirniy Avatar asked Sep 07 '12 10:09

Nikolas Papirniy


People also ask

Can we run JavaScript on JVM?

Embedded Script Engine The second and probably more common way to run JavaScript from within the JVM is via the ScriptEngine. JSR-223 defines a set of scripting APIs, allowing for a pluggable script engine architecture that can be used for any dynamic language (provided it has a JVM implementation, of course).

What is implementation in JavaScript?

Implement. js is a library that attempts to bring interfaces to JavaScript. The idea is simple: define an interface, define the types of it's properties, and use it to ensure an object is what you expect it to be.

Can Java and JavaScript be used together?

You can call JavaScript from Java using the Java Scripting Framework, but in this case, it's probably easiest to just translate your colleague's code to Java. It's not really long, is it? Java has a 'scripting engine' for evaluating for example JavaScript from Java.

What is JDK in JavaScript?

The JDK is a key platform component for building Java applications. At its heart is the Java compiler. IDG / Oracle / Vasabii / Getty Images. The Java Development Kit (JDK) is one of three core technology packages used in Java programming, along with the JVM (Java Virtual Machine) and the JRE (Java Runtime Environment) ...


2 Answers

Most current one seems to be Doppio

like image 67
Janus Troelsen Avatar answered Sep 21 '22 22:09

Janus Troelsen


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

like image 32
Steve Oh Avatar answered Sep 21 '22 22:09

Steve Oh