Giter Club home page Giter Club logo

nodyn's Introduction

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/

nodyn's People

Contributors

aslakknutsen avatar bbrowning avatar bnoordhuis avatar bobmcwhirter avatar danbev avatar danielpassos avatar jfsiii avatar lance avatar lholmquist avatar m0wfo avatar malaporte avatar mo-gr avatar qmx avatar sebastienblanc avatar t-beckmann avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.