Run Java in JavaScript

Last modified on January 12th, 2015 by Joe.

This discusses about how to run the Java platform within JavaScript engine in a browser. Standard way of running Java application in a browser is via Java Applets. Applets can provide high level of interactive features in a web browser that will exceed the ordinary capabilities of HTML. If you are looking to run JavaScript in Java, you should refer nashorn JavaScript engine.

JavaScript has no competitor when it comes to client-side scripting. With the advent of modern web and browsers JavaScript is even more thriving. With good JavaScript skill that combined with couple of libraries like jQuery, we can get a good job easily in the present market. In this scenario, I just had a thought to find out how much it is possible to run a Java JVM entirely within a JavaScript engine in a browser. Is there any work going on in this front and any libraries available that provides this support.

Orto JavaScript JVM

In 2008, John Resig has posted a blog post on Orto JavaScript JVM. We can run Java bytecode through Orto which produces a JavaScript  and that can embeded in a Web page. I couldn’t trace the source project URL for Orto and looks like presently it is not being maintained. Luckily some good Samaritan has posted the Orto project in GitHub . There is no information about the license terms and docs all are in Japanese.

Jainja Java to JavaScript

Jainja claims that all the major features of Java 1.5 specification is supported. A demo of Jainja JVM is available as a Chrome App. A Tetris game is hosted in appspot using this JVM and its quite impressive. Response of the application in the browser is sluggish. The project source is available and hosted at SourceForge.



This is an at building a JVM. This is more like a proof of concept (POC) and is not a full-fledged JVM. This is attractive in the sense, we can learn how and where to start for a similar project.

LLVM, VMKit and emscripten Combo

“LLVM Project is a collection of modular and reusable compiler, tool-chain technologies”.  VMKit project is an implementation of the Java and .NET VM that is built on LLVM. VMKit is not presently being maintained, but the code is available view their repository. emscripten is a LLVM-to-JavaScript compiler. It can convert the LLVM bitcode to JavaScript. So by combining these three, we should be able to run Java in JavaScript engine. VMKit is not presently maintained and given the use of these combo, it is not a promising idea to go for this.

Other Similar Java JVM

Among all the projects listed above, Bck2Brwsr and Doppio are the JavaScript Java JVM that looks promising. It will not be an easier task for these projects to catch up with Java 8.

Comments on "Run Java in JavaScript"

  1. Pratik says:

    Java Everywhere :)

  2. Sandeep says:

    DWR (Direct Web Remoting) is the great way to interact Java Script to Java and vice-versa.

Comments are closed for "Run Java in JavaScript".