import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import java.io.FileReader; public class Main { public static void main(String[] args
According to the documentation:
The window object represents an open window in a browser.
Since you are not executing your script in a browser, the window object is not defined.
You can read the URL using the URL/URLConnecion classes and feed it to the ScriptEngine. There is a tutorial here.