A simplified Make for Java 8 Nashorn

View the Project on GitHub winterbe/nake


Nake is a simplified version of Make (Cake, Jake, Rake) for the Java 8 Nashorn Javascript Engine.

You define tasks in a project specific nakefile.js and call them from the command line. Tasks are written in Javascript and run natively on the JVM by utilizing Nashorns jjs -scripting command. This enables you to utilize everything from the JDK 8 API or any external Java libraries.


Running nake with no arguments prints all tasks in the current directory's Nakefile.

Use nake -- taskName [options] to run a specific task from your Nakefile.


Use the following steps to install Nake on POSIX systems (Mac OSX, Linux):

$ cd /usr/bin
$ ln -s $JAVA_HOME/bin/jjs jjs
$ cd /usr/bin
$ ln -s /path/to/nake/src/nake.js nake

Nake also runs on Windows: Set PATH to nake.js directory; then run Nake with jjs -scripting nake.js -- taskName.

Getting started

Create a file called nakefile.js in your projects root directory with the following content:

task('hello', 'Hello World', function() {
  print('Hello World!');

Open the terminal, cd into any project directory and type nake -- hello.

Next, check out the API Documentation and example tasks. You should also consider reading my Nashorn Tutorial to get started with the Nashorn engine.


The java example found in test/java contains a sample java application with some basic java-related nake tasks:

Run the java application:

Invokes the java main method. Nake arguments will be passed to java.

task("run", "Run java application", function(options) {
    .exec("java com/winterbe/nake/java/Main ${options[0]}")

Run the task from your terminal:

nake -- run [arg]

Compile all java files:

Compiles all java files from src to out.

task("compile", "Compile all java files", function() {
    .exec("find src -name *.java")
    .apply(function(result) {
      return java.lang.String.join(" ", result.split("\n"));
    .print("compiling java files...")
    .exec("mkdir -p out")
    .exec("javac -d out {{files}}")

Run the task from your terminal:

nake -- compile

Keep in mind that you can run nake tasks from any subfolder of your project. Read the API Documentation for a detailed description.


Your Feedback is highly appreciated. Feel free to file an issue or ping me on Twitter or Google+.