I want to make this example to work: https://github.com/graalvm/graal-js-jdk11-maven-demo/blob/master/src/main/java/com/mycompany/app/App.java
But I get an exception in thread "main" java.lang.NoClassDefFoundError: jdk/vm/ci/services/Services
I included GraalVM via Maven
The same exception is thrown in this minimal example
import org.graalvm.polyglot.Context;
public class Main {
public static void main(String[] args) {
Context context = Context.create("js");
context.eval("js", "console.log('Hello from Earth')");
}
}
The pom
<dependencies>
<!-- https://mvnrepository.com/artifact/org.graalvm.sdk/graal-sdk -->
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>19.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.graalvm.js/js -->
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>19.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.graalvm.js/js-scriptengine -->
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>19.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.graalvm.compiler/compiler -->
<dependency>
<groupId>org.graalvm.compiler</groupId>
<artifactId>compiler</artifactId>
<version>19.1.1</version>
</dependency>
</dependencies>
I am using jdk-12.0.1 (Open JDK) and working on a Windows 10 computer.
Somewhere on the internet I found that this
-XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler
should be included as VM arguments. When I do that the exception changes to:
Exception in thread "main" java.lang.IllegalAccessError: class org.graalvm.compiler.truffle.runtime.hotspot.AbstractHotSpotTruffleRuntimeAccess (in unnamed module @0x2d8e6db6) cannot access class jdk.vm.ci.services.Services (in module jdk.internal.vm.ci) because module jdk.internal.vm.ci does not export jdk.vm.ci.services to unnamed module @0x2d8e6db6
Maybe there is a problem with the modules: modules-info.java
module App {
exports testinggraal;
requires org.graalvm.sdk;
requires java.scripting;
requires org.graalvm.truffle;
requires org.graalvm.js;
}