You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user/NodeJSVSJavaScriptContext.md
+3-7Lines changed: 3 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,13 +31,9 @@ In this scenario, Java classes can be exposed to the Node.js application by usin
31
31
## Java Interoperability
32
32
33
33
JavaScript applications can interact with Java classes using the `Java` built-in object.
34
-
The object is not available by default, and can be enabled in the following way:
34
+
This object is available by default in the `js`and `node` launchers, but accessing Java classes is only possible in the JVM standalones (that have `-jvm` in the name).
35
35
36
-
1. In Node.js mode, start GraalVM using the `bin/node --jvm` command.
37
-
2. In Java, create a GraalVM context using the `withHostInterop()` option, e.g.:
38
-
```java
39
-
Context.create("js").withHostInterop()
40
-
```
36
+
When embedding GraalVM JavaScript using the Polyglot API, you have to explicitly enable host access in the [`Context.Builder`](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/Context.Builder.html) (`allowHostAccess`, `allowHostClassLookup`).
41
37
More details on the Java interoperability capabilities of GraalVM JavaScript are available in [Java Interoperability](JavaInteroperability.md).
42
38
43
39
## Multithreading
@@ -57,7 +53,7 @@ More details on parallel execution in GraalVM JavaScript are available in [this
57
53
Java libraries can be accessed from JavaScript in GraalVM through the `Java` built-in object.
58
54
In order for a Java library to be accessible from a `Context`, its `jar` files need to be added to the GraalVM classpath. This can be done in the following way:
59
55
60
-
1. In Node.js mode, the classpath can be modified using the `--jvm.cp` option.
56
+
1. In Node.js mode, the classpath can be modified using the `--vm.cp` option.
61
57
2. In Java, the default Java's `-cp` option can be used.
62
58
63
59
More details on GraalVM command line options are available in [Options](Options.md).
0 commit comments