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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM