GithubHelp home page GithubHelp logo

nasven's Introduction

Nasven.js

What is Nasven? Quoting Lukas Eder:

    "Nasven = Nashorn + Maven. A tool to get Maven artifacts 
              in scope for Nashorn script execution."

Nasven allows developers to code Javascript applications that run on top of the Java Platform (using Nashorn engine) and that may have dependencies on Apache Maven artifacts. Developers can build pure server-side applications, shell scripts, or even JavaFX desktop applications, and any Maven dependency will be downloaded and configured in the classpath automatically.

Requirements

You must have installed in your environment the following softwares:

  • Java SE 8
  • Apache Maven 3+

Installation

You can install on your Linux-based environment with the following command:

    $ curl -sSL j.mp/installnasven | sh

Docker

You can use the Docker image nasven/nasven.js published in Docker Hub.

    # sudo docker run -it nasven/nasven.js /nasven/samples/helloworld

You can also map and run a local (on host) application:

    # sudo docker run -it -v `pwd`/samples/hellodocker:/app nasven/nasven.js

Example

The samples repository contains several Nasven applications. One of those samples is the jaxrs sample that uses the JAX-RS Client API. This sample application is coded inside the file index.js of the JAX-RS sample. Prior to Nasven.js, in order to run this application sample, a developer would have to download all the dependencies of JAX-RS Client API, and an implementation of the specification. But it is much easier to use Apache Maven to depend on those artifacts. The configuration of this sample application is defined in the file package.json. To run this application, use one of the following commands:

    $ jjs -scripting nasven.js -- samples/jaxrs
    
    $ ./nasven samples/jaxrs

You can read arguments inside your code with ''arguments[0]'', ''arguments[1]'', and so on.

Application Definition File package.json

Check the samples repositoryr for more examples of the package.json files with defined Maven dependencies.

Features

Every application executed with Nasven.js will have Nasven itself loaded to provide access to features defined in nasven.js:

  • require('path/to/file.js'): same as Nashorn load(), but only for local files and this will be watched for updates and reloaded on the fly.
  • daemon(): it will create a deamon Thread to keep the application up and running.
  • exec('command', suppress): same as Nashorn exec() except it will print output on demand if suppress is false. By default output is suppressed. Optional argument.
  • console.log('text'): same as print().

License

MIT

nasven's People

Contributors

brunoborges avatar lukaseder avatar

Watchers

James Cloos avatar Guillermo 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.