"A Cloud Approach to the Java Runtime Environment"
jsJVM is a specialised implementation of the Java Virtual Machine, written in JavaScript.
The primary goal of the project is;
Any user visiting the page can now execute the Java application without needing the JRE installed on their system. Any Java classes that are required by the application are downloaded to the client when needed and deleted when no longer required.
The jsJVM is used by deploying to a webpage in identical manner to
any standard JavaScript library.
Application class files must be then copied onto the web server and
made accessible to the webpage. The server must also hold a copy of
the Java API classes.
When the page is accessed, application class files are downloaded to the client and executed.
The following steps will result in a working copy of the jsJVM.
Download the latest minified JVM build and modified Java API:
$ wget https://github.com/downloads/Jivings/jsJVM/jvm-latest.tar.bz2
Extract the contents of the archive:
$ tar -xvjf jvm-latest.tar.bz2
Descend into the JRE directory:
$ cd deploy/jre
Extract the system JRE:
$ cd rt jar xf $JAVA_HOME/jre/lib/rt.jar
The jsJVM is then deployed by including a link to the file in any web page:
<script type="test/javascript" src="jvm.js"></script>
If you would prefer to install the latest master version of jsJVM, you can clone the source repository or download the source directly
The jsJVM itself is written in CoffeeScript, thus to build from source you must have a working copy of the CoffeeScript compiler. The build process can then be invoked from the project directory:
cake buildThe above steps can then be followed for deployment.
The jsJVM is started by creating an instance and providing the name of the applications main class:
new jvm({ classname : 'HelloWorld' });
HelloWorld represents a .class file which resides on the server.
The JVM will then execute the Java application in the clients web browser.
For additional customisation, several more options can be passed to the jsJVM on initialisation. These are as follows:
Variable | Default Value | Description |
---|---|---|
classpath | . [current directory] | The path to the Java API Classes |
path | . [current directory] | The path to the Application Classes |
workerpath | $classpath/workers | The path to the worker Classes |
stdin | stdin | The ID of the page element from which to take input. |
stdout | stdout | The ID of the page element to which to print output |
stderr | stderr | The ID of the page element to which to print error output |
verbosity | warn | The verbosity level. 'warn' to print warnings and errors to stderr, 'error' to only print errors to stderr, or 'none' to suppress all errors and warnings |