How to include JavaScript file in Java program

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 05:52:44
Erik

Require is not a part of standard javascript, but a feature of NodeJS. Your JAVA program doesn´t know how to deal with it.

See also this question and its accepted answer:

What is this Javascript "require"?

Juan Mendes

The scripting engine doesn't have access to objects (require) added to JavaScript by PhantomJS/nodejs

You can execute phantom using exec. Something like

 // You need the correct path for phantomJs
 Process process = Runtime.getRuntime().exec("/usr/bin/phantomjs myScript.js");

See https://stackoverflow.com/a/16891381/227299

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!