I have been using ClearScript for .NET for quite a long time. I have been exposing C# functions and classes to javascript like this: engine.AddHostObject("ftp", new ftp());
After that I could do engine.eval("ftp.upload(""));
I have been trying to do something similar with nashorn for java but I can't figure it out. What would be the easiest way to do it.
I think this code is the Nashorn equivalent of what you've posted.