Using Graal.js, how can I import a java class to script within JS?
The following code works with Nashorn JJS, but does not work with Graal.js because there is no Java.type() in graal, do I need to invoke truffle at some point?
var ArrayList = Java.type("java.util.ArrayList");
var myList = new ArrayList();
myList.add("hello");
myList.add("world");
print(myList);
EDIT: I was able to get it to import java types using the --jvm paramter, which seems to indicate that it runs it on the JVM. So does this completely pas over the GraalVM and just use the JVM?
--jvmyou are still running with Graal.js. It's a mode where you run Graal.js inside the JVM which gives you access to all the JVM features. The default mode (--native) runs in a pre-compiled native binary that is faster to start-up but does not support loading Java classes.