{"record":{"id":"9b18cf6ab0cf76c7","repo":"Konloch/bytecode-viewer","slug":"cannot-find-javascript-script-engine-please-conta","errorCode":null,"errorMessage":"Cannot find Javascript script engine! Please contact Konloch.","messagePattern":"Cannot find Javascript script engine! Please contact Konloch\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavascriptPluginLaunchStrategy.java","lineNumber":60,"sourceCode":"    //fallback to graal.js\n    public static final String FALL_BACK_ENGINE = \"graal.js\";\n\n    //can we use the JS engine\n    public static final boolean IS_JS_ENGINE_IN_CLASSPATH = isJSEngineInClassPath();\n\n    @Override\n    public Plugin run(File file) throws Throwable\n    {\n        ScriptEngineManager manager = new ScriptEngineManager();\n        ScriptEngine engine = manager.getEngineByName(FIRST_PICK_ENGINE);\n\n        //nashorn compatability with graal\n        if (engine == null)\n        {\n            engine = manager.getEngineByName(FALL_BACK_ENGINE);\n\n            if (engine == null)\n                throw new Exception(\"Cannot find Javascript script engine! Please contact Konloch.\");\n\n            Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);\n            bindings.put(\"polyglot.js.allowHostAccess\", true);\n            bindings.put(\"polyglot.js.allowAllAccess\", true);\n            bindings.put(\"polyglot.js.allowHostClassLookup\", true);\n        }\n\n        Reader reader = new FileReader(file);\n        engine.eval(reader);\n\n        ScriptEngine finalEngine = engine;\n\n        return new Plugin()\n        {\n            @Override\n            public void execute(List<ClassNode> classNodeList)\n            {\n                try","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Konloch/bytecode-viewer/blob/31430e0033fa220db566b5ef461256727ff6793b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavascriptPluginLaunchStrategy.java#L42-L78","documentation":"Thrown by JavascriptPluginLaunchStrategy.run when the JVM's ScriptEngineManager cannot resolve a JavaScript engine. BCV first tries the primary engine name and then the GraalVM fallback engine; if both return null, no JS script engine (Nashorn or GraalJS) is present on the classpath, so plugin launching cannot proceed. The message asks users to contact the author because it indicates a broken/partial dependency set.","triggerScenarios":"Launching a JavaScript (.js) plugin via JavascriptPluginLaunchStrategy.run on a JVM where neither the primary engine nor FALL_BACK_ENGINE (GraalJS) is registered — e.g. running on Java 15+ where the built-in Nashorn engine was removed and GraalJS is not on the classpath.","commonSituations":"Running BCV on JDK 15+ (Nashorn removed from the JDK) without adding graal-js/openjdk-nashorn to the classpath; using a JRE-only distribution without scripting providers; shaded/trimmed jars that dropped the ScriptEngine provider files under META-INF/services.","solutions":["Add a JavaScript ScriptEngine to the classpath: org.graalvm.js:graal-js and graal-js-engine (or org.openjdk.nashorn:nashorn-core) matching your JDK version","On Java 8-14, run with a JDK that still bundles Nashorn instead of a newer JRE","Verify the engine resolves before launching with new ScriptEngineManager().getEngineByName(\"js\") and log the result","If using a trimmed/fat jar, rebuild it so META-INF/services scripting provider registration files are preserved"],"exampleFix":"// before (pom.xml, Java 15+, no JS engine)\n<dependency>\n  <groupId>org.graalvm.js</groupId>\n  <artifactId>graal-js</artifactId>\n</dependency>\n// after\n<dependency>\n  <groupId>org.graalvm.js</groupId>\n  <artifactId>graal-js</artifactId>\n</dependency>\n<dependency>\n  <groupId>org.graalvm.js</groupId>\n  <artifactId>graal-js-engine</artifactId>\n</dependency>","handlingStrategy":"fallback","validationCode":"ScriptEngine engine = new ScriptEngineManager().getEngineByName(\"js\");\nif (engine == null) throw new IllegalStateException(\"No JavaScript engine on classpath; add graal-js or nashorn-core\");","typeGuard":null,"tryCatchPattern":"try {\n    plugin = jsStrategy.run(file);\n} catch (Exception e) {\n    if (e.getMessage().contains(\"Cannot find Javascript script engine\")) {\n        // alert user to install a JS engine / switch JDK\n    } else throw e;\n}","preventionTips":["Bundle graal-js + graal-js-engine (or nashorn-core) with your distribution","Pin the JDK version known to ship or support your JS engine","Smoke-test engine availability at startup, before any plugin launch","Keep META-INF/services scripting provider files intact in shaded jars"],"tags":["java","scripting","nashorn","graaljs","classpath"],"backgroundTag":"missing-script-engine","analyzedSha":"31430e0033fa220db566b5ef461256727ff6793b","analyzedAt":"2026-09-05T18:22:22.725Z","contentChangedAt":"2026-09-05T18:22:22.725Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}