Skip to content

Commit

Permalink
Add simple Main program that executes a hard-coded JS file
Browse files Browse the repository at this point in the history
  • Loading branch information
skinny85 committed Sep 26, 2024
1 parent 55e59b8 commit ad683cc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions part-16/src/main/java/com/endoflineblog/truffle/part_15/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.endoflineblog.truffle.part_15;

import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;

import java.io.File;
import java.io.IOException;

public class Main {
public static void main(String[] args) throws IOException {
Source source = Source
.newBuilder("ezs", new File("src/main/resources/example.js"))
.build();

try (Context context = Context
.newBuilder()
.build()) {
Value result = context.eval(source);
System.out.println(result.toString());
}
}
}
1 change: 1 addition & 0 deletions part-16/src/main/resources/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"example.js";

0 comments on commit ad683cc

Please sign in to comment.