-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple Main program that executes a hard-coded JS file
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
part-16/src/main/java/com/endoflineblog/truffle/part_15/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"example.js"; |