Konloch/bytecode-viewer · error · Exception
Cannot find Javascript script engine! Please contact Konloch
Error message
Cannot find Javascript script engine! Please contact Konloch.
What it means
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.
Source
Thrown at src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavascriptPluginLaunchStrategy.java:60
//fallback to graal.js
public static final String FALL_BACK_ENGINE = "graal.js";
//can we use the JS engine
public static final boolean IS_JS_ENGINE_IN_CLASSPATH = isJSEngineInClassPath();
@Override
public Plugin run(File file) throws Throwable
{
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName(FIRST_PICK_ENGINE);
//nashorn compatability with graal
if (engine == null)
{
engine = manager.getEngineByName(FALL_BACK_ENGINE);
if (engine == null)
throw new Exception("Cannot find Javascript script engine! Please contact Konloch.");
Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
bindings.put("polyglot.js.allowHostAccess", true);
bindings.put("polyglot.js.allowAllAccess", true);
bindings.put("polyglot.js.allowHostClassLookup", true);
}
Reader reader = new FileReader(file);
engine.eval(reader);
ScriptEngine finalEngine = engine;
return new Plugin()
{
@Override
public void execute(List<ClassNode> classNodeList)
{
tryView on GitHub (pinned to 31430e0033)
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
Example fix
// before (pom.xml, Java 15+, no JS engine) <dependency> <groupId>org.graalvm.js</groupId> <artifactId>graal-js</artifactId> </dependency> // after <dependency> <groupId>org.graalvm.js</groupId> <artifactId>graal-js</artifactId> </dependency> <dependency> <groupId>org.graalvm.js</groupId> <artifactId>graal-js-engine</artifactId> </dependency>
Defensive patterns
Strategy: fallback
Validate before calling
ScriptEngine engine = new ScriptEngineManager().getEngineByName("js");
if (engine == null) throw new IllegalStateException("No JavaScript engine on classpath; add graal-js or nashorn-core"); Try / catch
try {
plugin = jsStrategy.run(file);
} catch (Exception e) {
if (e.getMessage().contains("Cannot find Javascript script engine")) {
// alert user to install a JS engine / switch JDK
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot find Jython script engine! Please contact Konloch.
- Cannot find jRuby script engine! Please contact Konloch.
- Invalid internal class name
- Unknown constant pool tag ${tag}
- null key or factory
AI-assisted analysis of Konloch/bytecode-viewer@31430e0033 (2026-09-05).
Data as JSON: /api/errors/9b18cf6ab0cf76c7.
Report an issue: GitHub.