Call javascript function from kotlin JVM based project
问题 Is is possible to call javascript functions from kotlin JVM based project? Like for example I got class: class JS{ fun callJS( ){ // somehow call js function } } 回答1: You can use a ScriptEngineManager with JavaScript as the engine. You use ScriptEngineManager.getEngineByName to get the engine itself, but that doesn't allow calling methods from Java. In order to do this, you need an Invocable. This is done by first eval uating the script (either as a Reader or String) and then casting it as an