The java have a script manager that allow java calling javascript, like this:
import javax.script.*; public class ExecuteScript { public static void main(St
I'm not sure what script manager you are using but with Rhino you can do things like
var date = new java.util.Date(); print(date);
So with your example you should be able to call it like a static method:
ExecuteScript.sayHi();