其他分享
首页 > 其他分享> > graalvm 简单试用

graalvm 简单试用

作者:互联网

安装

http://www.graalvm.org/downloads/
linux:
export PATH=/path/to/graalvm/bin:$PATH
mac:
export PATH=/path/to/graalvm/Contents/Home/bin:$PATH

基本代码编写

import java.io.*;
import java.util.stream.*;
import org.graalvm.polyglot.*;

public class PrettyPrintJSON {
  public static void main(String[] args) throws java.io.IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String input = reader.lines().collect(Collectors.joining(System.lineSeparator()));
    try (Context context = Context.create("js")) {
      Value parse = context.eval("js", "JSON.parse");
      Value stringify = context.eval("js", "JSON.stringify");
      Value result = stringify.execute(parse.execute(input));
      System.out.println(result.asString());
    }
  }
}

参考架构图

参考资料

http://www.graalvm.org/docs/getting-started/#combine-languages

 

   

标签:java,import,System,parse,试用,简单,PATH,graalvm
来源: https://www.cnblogs.com/javalinux/p/15791016.html