Debugging Polyglot Applications on GraalVM in VS Code

Martin Balín
Jun 23 · 3 min read

GraalVM provides users with the unique ability to mix languages and create polyglot solutions. However, it can be a challenge to debug such programs using traditional IDEs. To support this, GraalVM offers true Polyglot debugging capabilities in its own GraalVM Extension Pack for VS Code. After installing it, you can debug not only GraalVM supported guest languages using the Debug Adapter protocol or Chrome Inspector, but also Java programs combined with GraalVM guest languages.

Get Ready

Assuming you have VSCode installed, go to the Extensions activity panel, search for “GraalVM Extension Pack”. Installing it will automatically download and install all three of the extensions it includes.

GraalVM Extension Pack
GraalVM Extension Pack

Polyglot debugging only works with GraalVM, so make sure a GraalVM install is configured. It can be installed using the VSCode Gr activity panel either by selecting Download or by choosing the existing GraalVM installation from your disk. Set just installed GraalVM as “Active GraalVM installation” when asked. This way VSCode will use this GraalVM installation as its Java platform internally.

GraalVM “Gr” activity panel in VSCode.
GraalVM “Gr” activity panel in VSCode.

To test it, navigate to GraalVM Demos on GitHub, and clone the sample polyglot-debug. This sample is Java & JavaScript, but any other scripting language supported by GraalVM will work as well.


After cloning the sample project, open the polyglot-debug folder using File | Open Folder.

Open the main class Java file PolyglotDebug.javaand/or the fib.js file located in resources/org/graalvm/demos.

Place the breakpoint either in the Java file or JS file.

Go to Run and Debug or simply press F5. Choose “Launch Java 8+ underneath “powered by Apache NetBeans Language Server,” as this is the Polyglot debugger provided by GraalVM extensions. You need to run your polyglot program with this launch configuration since other Java launch configs don’t support polyglot debugging.

GraalVMs “Launch Java 8+ App” configuration for polyglot debugging.
GraalVMs “Launch Java 8+ App” configuration for polyglot debugging.

It is possible to step through Java code as well as JS code (in this sample), watch variables in both languages, place breakpoints, etc. It works as expected, like any real debugger.

Project Structure

In this case there is one Java file which calls a function from JavaScript. The JS file itself is placed in the resources folder so it is packaged by Maven and available for GraalVM to be executed at any time. This approach, when JS is in a separate file, offers better clarity when debugging JS. It is possible to place JS code inline inside Java, but then it is harder to place a breakpoint or step into such code.

Inlining JS could look like this:

The advantage of \nis that Truffle then displays the script with newlines, making debugging easier than in the case of inlined script.

GraalVM VSCode extensions work with Maven and Gradle projects.


Our goal is to make complex things simple using GraalVM and the VSCode extension. Give it a try:

We always welcome feedback and feature requests on Github, Slack, or Twitter. Stay tuned for the next GraalVM debugger story and more!


GraalVM team blog -