This demo is intended to be used to demonstrate how to debug a Java application, built into a native executable, using GraalVM VS Code Extension Pack for Java.
- Linux OS with GDB 10.1
- Visual Studio Code
- GraalVM Extension Pack for Java: Open Visual Studio Code, navigate to Extensions activity panel in the left-hand side Activity Bar (or use the Ctrl+Shift+X hot keys combination). Search for “GraalVM” in the search field. Find "GraalVM Extension Pack for Java", press Install. Reload will be required.
- GraalVM runtime environment in VS Code: Navigate to Gr activity panel in VS Code and install some of the latest GraalVM Enterprise Edition versions available from the list.
- Native Image: Upon GraalVM's installation completion, the “Install Optional GraalVM Components” window pops up in the right bottom corner. Install Native Image.
-
Clone Download or clone the GraalVM Demos repository:
git clone https://github.com/graalvm/graalvm-demos
-
Open the demo folder, graalvm/demos/javagdbnative, in VS Code.
-
Open VS Code Terminal window and run following command:
mvn -Pnative -DskipTests package
The mvn -Pnative -DskipTests package
command will package a Java application into a runnable JAR file, and then build a native executable of it.
- Select Run and Debug activity panel in VSCode
- Add a new launch configuration named Native Image: launch into launch.json which should look like this:
{ "type": "nativeimage", "request": "launch", "name": "Launch Native Image", "nativeImagePath": "${workspaceFolder}/target/javagdb", "args": "100" }
- Then run debugger using Launch Native Image from RUN... menu. It will start debugging a native image binary in VSCode using Java source code.