Skip to content
Javascript Java VM
Java JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.settings
data
deploy
src
.classpath
.gitignore
.project
README.md
pom.xml

README.md

ch.ri.jsjvm

Overview

jsjvm is a java virtual machine for javascript.

Features

To this date, all that works is a simple proof of concept "Hello world" program.

Data generation

The classes are parsed with the asm framework and a json representation of the class-definition is supplied to the jsjvm.js.

//Create instance
var vm = new jsjvm.VM();

//Inject class definition
vm.classes.put('ch.ri.jsjvm.test.utils.StaticDeploy$Main', {"name":"ch.ri.jsjvm.test.utils.StaticDeploy$Main","methods":"..."});

//Execute main class
vm.execute('ch.ri.jsjvm.test.utils.StaticDeploy$Main');

Examples

Static deployment

There is a static example in the "deploy" folder. After checking out the repo the index.html should alert you a message in the browser.

Java Class

This is the java class supplied in the static deployment:

public static class Main
{
    /**
     * @param args
     */
    public static void main(String[] args)
    {

        MyClass t = new MyClass();
        t.stuff();

    }
}

public static class MyClass
{
    public MyClass()
    {
        this.msg = "Hello";
    }

    private String msg;

    public void stuff()
    {
        this.otherStuff();
    }

    public void otherStuff()
    {
        window.alert(msg);
    }
}

Maven

Maven dependency:

<dependency>
    <groupId>ch.ri</groupId>
    <artifactId>jsjvm</artifactId>
    <version>1.0</version>
</dependency>

Repository:

<repositories>
    <repository>
        <id>Rudin-Informatik</id>
        <name>Thomas Rudin</name>
        <url>http://rudin-informatik.ch/maven2</url>
        <layout>default</layout>
    </repository>
</repositories>

Version History

1.1-SNAPSHOT

  • TODO

1.0

  • Instance-Based "Hello world" works.
Something went wrong with that request. Please try again.