How to get Graal SDK packages to work without Maven?

后端 未结 5 1105
夕颜
夕颜 2021-02-06 04:55

I am developing a Java application that needs to execute JavaScript. Nashorn JS engine is about to get deprecated and the replacement is the set of APIs provided by Graal SDK wh

5条回答
  •  轮回少年
    2021-02-06 05:32

    Using both IntelliJ (2020.2) and GraalVM (graalvm-ce-java11-20.3.0) I was able make the following code work:

    public static void main(String[] a0rgs) {
        System.out.println("Hello World!");
        Context context = Context.create();
        context.eval("js", "console.log('hello from javascript');");
    }
    

    Just by adding this dependency to maven:

    
        org.graalvm.sdk
        graal-sdk
        20.3.0
    
    

提交回复
热议问题