我可以从脚本加载一个罐子(并使用它)吗?



我有一个运行Nashorn的Java程序(默认情况下(。

engine = new javax.script.ScriptEngineManager().getEngineByName("JavaScript");
engine.eval(someCode); // how can I have 'someCode' to load some jar ?

我想知道 Nashorn/JavaScript 是否有可能加载一个新的 jar(比如说从 URL(然后访问它。

在上面的片段中,它的意思是:">someCode">会是什么样子?

我在这里找到了一个可能的解决方案:https://github.com/lorenzoongithub/nudge4j/blob/master/docs/proxy/load.examples.js#L152-L158

但感觉有点闷闷不乐。此外,看起来它可能会在Java 9上崩溃

https://www.reddit.com/r/java/comments/5z3tmf/a_blooming_good_tostring/devarrt/

谢谢

但目前你只需要使用类加载器。黑客的方式

最新更新