Learn · concepts

What Is GraalVM JavaScript Scripting?

GraalVM JavaScript is a fast JS engine that runs on the JVM. It lets Java apps embed JavaScript so users can script features and reload them instantly.

TRtrolPublished 3 min read

What is GraalVM JavaScript?

GraalVM JavaScript is a fast, standards-compliant JavaScript engine that runs on the JVM, part of the GraalVM project. Java applications embed it so users can write JavaScript that calls into the host program and reloads on the fly. In a Java application, that means adding or changing behavior in JavaScript without recompiling the Java code.

Think of it as a sandbox for adding features. The application exposes certain objects and methods to a script, and the script calls those methods to do work inside the app. When you change the script and save it, the engine reloads it immediately, no restart required.

Why apps embed scripting engines

Applications like Minecraft clients embed JavaScript engines for a few practical reasons:

  • Hot reload: change a script and see the effect without restarting or rebuilding.
  • A safe surface: the host decides exactly which objects and Java classes a script can touch.
  • Fast iteration: test new behavior in seconds instead of minutes of compile time.
  • User customization: let players write their own features in a familiar language.

How it shows up in a client

A client that embeds GraalVM JavaScript usually gives scripts an entry point to register themselves, then a small set of proxy objects that bridge JavaScript to the program's internals. Users write a script, drop it in a scripts folder, and the engine loads it. This is how a client can let users add features in JavaScript instead of compiling a mod.

GraalVM JavaScript vs Node.js

AspectGraalVM JavaScriptNode.js
RuntimeRuns on the JVMStandalone V8-based runtime
Use caseEmbedded in Java appsServer-side JavaScript or CLI tools
StartupPart of host processSeparate process
AccessHost exposes specific objectsFull OS access
PerformanceJIT compiled, very fastAlso very fast, different trade-offs

Both are excellent at running JavaScript; they're just built for different contexts. GraalVM is the right fit when you want a Java app to let users script in JavaScript.

FAQ