Skip to content
forked from nodyn/nodyn

A node.js compatible framework running on the JVM.

License

Notifications You must be signed in to change notification settings

lemonhall/nodyn

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

What is Nodyn

Nodyn is a node.js compatible framework on the JVM.

Run node.js applications on the JVM and access to all that the Java world has to provide - directly from Javascript. You've got the entire Java ecosystem at your disposal. Nodyn supports NPM module loading and a large portion of the current node.js API.

Usage

Nodyn doesn't yet have an initial release. Until then, to use it, you will need to build from source or download a CI SNAPSHOT from Sonatype. Download the latest zip file from Sonatype. It will contain a ./bin/nodyn binary. You can use the binary to start an application from a Javascript file, or use the REPL to experiment with small snippets of code on the command line. The ./bin/nodyn binary behaves nearly identical to the node binary.

Embedding

Nodyn can be embedded into existing Java programs and exeucte scripts like so.

public class EmbedExample {

    private static final String SCRIPT = "" +
            "var main = require('./project/main.js');" +
            "main.run();";


    public void runMain(String... args) throws InterruptedException {
        // Use DynJS runtime
        RuntimeFactory factory = RuntimeFactory.init(
            EmbedExample.class.getClassLoader(), 
            RuntimeFactory.RuntimeType.DYNJS);

        // Set config to run main.js
        NodynConfig config = new NodynConfig( new String[] { "-e", SCRIPT } );

        // Create a new Nodyn and run it
        Nodyn nodyn = factory.newRuntime(config);
        nodyn.setExitHandler( new NoOpExitHandler() );
        try {
            int exitCode = nodyn.run();
            if (exitCode != 0) {
                throw new TestFailureException();
            }
        } catch (Throwable t) {
            throw new TestFailureException( t );
        }
    }
}

Building Nodyn

To build nodyn from source, first check out the repo. Since nodyn uses node.js sources for the javascript layer, you will also need to run git submodule init and git submodule update the first time you build.

$ git clone https://github.com/nodyn/nodyn.git
$ cd nodyn
$ git submodule init
$ git submodule update
$ mvn install -s support/settings.xml

Website

http://nodyn.io/

About

A node.js compatible framework running on the JVM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 51.4%
  • Java 47.6%
  • Other 1.0%