Don't fork me!

Travis CI status: Build Status

1. Introduction

build
./mvnw -Pdocs

Initially generated by using generator-jvm yeoman generator (java-parent-multi-project)

2. Implementation

2.1. hello-nashorn

using Runnable interface (js code must have run function
package daggerok.runnableapp

import javax.script.Invocable
import javax.script.ScriptEngineManager

fun main(args: Array<String>) {
    val engine = ScriptEngineManager().getEngineByName("nashorn")
    engine.eval("""
      function greet(name) {
        return "Hello, " + name + "!";
      }
      var greeting = "Ololo-Trololo";
      function run() {
        print("greet('" + greeting + "') = '" + greet(greeting) + "'");
      }
    """)
    val invocable = engine as Invocable
    val runnable = invocable.getInterface(Runnable::class.java)
    runnable.run()
}
create simple java.js app
package daggerok.hellonashornapp

import javax.script.Invocable
import javax.script.ScriptEngineManager

fun main(args: Array<String>) {
    val engine = ScriptEngineManager().getEngineByName("nashorn")
    engine.eval("""
      function greet(name) {
        return "Hello, " + name + "!";
      }
    """)
    val invocable = engine as Invocable
    println(invocable.invokeFunction("greet", "World"))
    println(invocable.invokeFunction("greet", "Maksimko"))
}

Initially generated by using generator-jvm yeoman generator (kotlin)