<div dir="ltr"><div dir="ltr"><div dir="ltr">Here's the Gradle dependencies I used (I install X3DJSAIL in my ~/.m2/repository) that actually make the code work:<div><br></div><div><div>    implementation 'org.graalvm.sdk:collections:24.0.0'</div><div>    //implementation 'org.graalvm.js:js:23.0.3'</div><div>    implementation 'org.graalvm.polyglot:js-community:24.0.0'</div><div>    implementation 'org.graalvm.js:js-launcher:24.0.0'</div><div>    implementation 'org.graalvm.js:js-scriptengine:24.0.0'</div><div>    implementation 'org.graalvm.sdk:graal-sdk:24.0.0'</div><div>    implementation 'org.graalvm:launcher-common:1.0.0-rc7'</div><div>    implementation 'org.graalvm.sdk:nativeimage:24.0.0'</div><div>    implementation 'org.graalvm.polyglot:polyglot:24.0.0'</div><div>    implementation 'org.graalvm.regex:regex:24.0.0'</div><div>    implementation 'org.graalvm.truffle:truffle-api:24.0.0'</div><div>    implementation 'org.graalvm.truffle:truffle-compiler:24.0.0'</div><div>    implementation 'org.graalvm.shadowed:icu4j:24.0.0'</div><div>    implementation 'org.graalvm.truffle:truffle-runtime:24.0.0'</div><div><br></div><div>    implementation 'org.web3d.x3d:X3DJSAIL:4.0-SNAPSHOT'</div></div><div><br></div><div>So with this I will now test from NetBeans.  Works, except perhaps JavaScript compilation is not supported.</div><div><br></div><div>Here's my project:</div><div><a href="https://github.com/coderextreme/Jaminate">coderextreme/jaminate: High level animation tool for generating chained event ROUTEs and nodes in VRML. (github.com)</a><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 27, 2024 at 5:37 PM John Carlson <<a href="mailto:yottzumm@gmail.com">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Here's some steps for calling JavaScript from Java which calls JavaScript<div><br></div><div>Use these imports:</div><div><br></div><div><div>import org.graalvm.polyglot.Context;</div><div>import org.graalvm.polyglot.HostAccess;</div><div>import org.graalvm.polyglot.Engine;</div><div>import org.web3d.x3d.jsail.Core.X3D;</div></div><div><br></div><div>Here is example Java to load and execute JavaScript.  It is based on DISWebGateway code, but VERY different!</div><div><br></div><div><div>    public X3D JavaScriptExec(String javaScriptString)</div><div>      {</div><div>          X3D X3D0 = null;</div><div>          try</div><div>          {</div><div>            Engine engine = Engine.newBuilder("js").build();</div><div>            Context context = Context.newBuilder("js")</div><div>                .engine(engine)</div><div>                .allowHostAccess(HostAccess.ALL)</div><div>                .allowHostClassLookup(className -> true)</div><div>                .arguments("js", new String[]{"--jvm", "--vm.classpath=lib/X3DJSAIL.4.0.full.jar;lib/saxon-he-12.1.jar"})</div><div>                .option("js.ecmascript-version", "2022").build();</div><div>            context.eval("js", javaScriptString).asHostObject();</div><div>            X3D0 = context.eval("js", "X3D0").asHostObject();</div><div>            context.close();</div><div>            engine.close();</div><div>          } catch(Exception e) {</div><div>              e.printStackTrace(System.err);</div><div>          }</div><div>          return X3D0;</div><div>      }</div><div>    private void loadJsFile(GenericTableModel model, File selectedFile) {</div><div>         this.model = model;</div><div>         System.err.println("Opening file "+selectedFile);</div><div>         try (FileInputStream fis = new FileInputStream(selectedFile)){</div><div>            try (BufferedReader br = new BufferedReader(new InputStreamReader(fis, "UTF-8"))) {</div><div>                StringBuilder sb = new StringBuilder();</div><div>                String line;</div><div>                while ((line = br.readLine()) != null) {</div><div>                    sb.append(line);</div><div>                    sb.append("\n");</div><div>                }</div><div>                String jsCode = sb.toString();</div><div>                X3D X3D0 = this.JavaScriptExec(jsCode);</div><div>                System.err.println("Version: "+X3D0.getVersion());</div><div>                System.err.println("Profile: "+X3D0.getProfile());</div><div><br></div><div>            } catch (IOException e) {</div><div>                e.printStackTrace(System.err);</div><div>            }</div><div>            System.err.println("Number of rows in reader "+model.getModel().getRowCount());</div><div>        } catch (IOException e) {</div><div>            e.printStackTrace(System.err);</div><div>        }</div><div>    }</div></div><div><br></div><div>============================================================</div><div>I compile with Gradle, but don't run inside Gradle.</div><div><br></div><div>Here's some Gradle config:</div><div><br></div><div><div>// <a href="https://mvnrepository.com/artifact/org.graalvm.sdk/graal-sdk" target="_blank">https://mvnrepository.com/artifact/org.graalvm.sdk/graal-sdk</a></div><div>    implementation 'org.graalvm.sdk:graal-sdk:24.0.0'</div><div>    // <a href="https://mvnrepository.com/artifact/org.graalvm.js/js-launcher" target="_blank">https://mvnrepository.com/artifact/org.graalvm.js/js-launcher</a></div><div>    implementation 'org.graalvm.js:js-launcher:24.0.0'</div><div>    // <a href="https://mvnrepository.com/artifact/org.graalvm.js/js-scriptengine" target="_blank">https://mvnrepository.com/artifact/org.graalvm.js/js-scriptengine</a></div><div>    implementation 'org.graalvm.js:js-scriptengine:24.0.0'</div><div>    // <a href="https://mvnrepository.com/artifact/org.graalvm.js/js" target="_blank">https://mvnrepository.com/artifact/org.graalvm.js/js</a></div><div>    implementation 'org.graalvm.js:js:23.0.3'</div><div>    // implementation 'org.graalvm.js:js:24.0.0'</div><div>    // <a href="https://mvnrepository.com/artifact/org.graalvm.truffle/truffle-api" target="_blank">https://mvnrepository.com/artifact/org.graalvm.truffle/truffle-api</a></div><div>    implementation 'org.graalvm.truffle:truffle-api:24.0.0'</div><div>    // <a href="https://mvnrepository.com/artifact/org.graalvm.shadowed/icu4j" target="_blank">https://mvnrepository.com/artifact/org.graalvm.shadowed/icu4j</a></div><div>    implementation 'org.graalvm.shadowed:icu4j:24.0.0'</div><div>    // <a href="https://mvnrepository.com/artifact/org.graalvm/launcher-common" target="_blank">https://mvnrepository.com/artifact/org.graalvm/launcher-common</a></div><div>    implementation 'org.graalvm:launcher-common:1.0.0-rc7'                                                                                                                                                           // <a href="https://mvnrepository.com/artifact/org.graalvm.regex/regex" target="_blank">https://mvnrepository.com/artifact/org.graalvm.regex/regex</a>                                                                                                                                                    implementation 'org.graalvm.regex:regex:24.0.0'                                                                                                                                                                  implementation 'org.web3d.x3d:X3DJSAIL:4.0-SNAPSHOT'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               //implementation 'org.graalvm.tools:profiler:24.0.0'                                                                                                                                                             //implementation 'org.graalvm.tools:chromeinspector:24.0.0'                                                                                                                                                      // needs newer                                                                                                                                                                                                   //implementation 'org.graalvm.compiler:compiler:24.0.0'                                                                                                                                                              // <a href="https://mvnrepository.com/artifact/org.graalvm.truffle/truffle-compiler" target="_blank">https://mvnrepository.com/artifact/org.graalvm.truffle/truffle-compiler</a>                                                                                                                                       implementation 'org.graalvm.truffle:truffle-compiler:24.0.0'                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       implementation 'org.graalvm.polyglot:polyglot:24.0.0'                                                                                                                                                            implementation 'org.graalvm.sdk:collections:24.0.0'                                                                                                                                                              // implementation 'org.graalvm.sdk:nativeimage:24.0.0'                                                                                                                                                                                                                                                                                                                                                                            // implementation 'org.graalvm.polyglot:js:24.0.0'                                                                                                                                                               // Select tools: profiler, inspect, coverage, dap, tools                                                                                                                                                         implementation 'org.graalvm.polyglot:tools:24.0.0'                                                                                                                                                                                                                                                                                                                                                                                // <a href="https://mvnrepository.com/artifact/org.graalvm.polyglot/js-community" target="_blank">https://mvnrepository.com/artifact/org.graalvm.polyglot/js-community</a>                                                                                                                                          implementation 'org.graalvm.polyglot:js-community:24.0.0'</div></div><div>============================================================</div><div>Here's how I run my program:</div><div><br></div><div>/c/graalvm-jdk-22_windows-x64_bin/graalvm-jdk-22+36.1/bin/java.exe -cp "build/classes/java/main;C:/Users/john/pythonSAI/X3DJSAIL.4.0.full.jar;build/install/app/lib/tagsoup-1.2.1.jar;lib/graal/collections-24.0.0.jar;lib/graal/graaljs.jar;lib/graal/graaljs-launcher.jar;lib/graal/graaljs-scriptengine.jar;lib/graal/graal-sdk.jar;lib/graal/launcher-common.jar;lib/graal/nativeimage-24.0.0.jar;lib/graal/polyglot-24.0.0.jar;lib/graal/tregex.jar;lib/graal/truffle-api.jar;lib/graal/truffle-compiler-24.0.0.jar;lib/graal/truffle-icu4j.jar;lib/graal/truffle-runtime-24.0.0.jar;." net.coderextreme.jaminate.TableLoadSave<br></div><div><br></div><div>Here's my lib folder:</div><div><br></div><div><div>lib/graal/collections-24.0.0.jar</div><div>lib/graal/graal-sdk.jar</div><div>lib/graal/graaljs-launcher.jar</div><div>lib/graal/graaljs-scriptengine.jar</div><div>lib/graal/graaljs.jar</div><div>lib/graal/launcher-common.jar</div><div>lib/graal/nativeimage-24.0.0.jar</div><div>lib/graal/polyglot-24.0.0.jar</div><div>lib/graal/tregex.jar</div><div>lib/graal/truffle-api.jar</div><div>lib/graal/truffle-compiler-24.0.0.jar</div><div>lib/graal/truffle-icu4j.jar</div><div>lib/graal/truffle-runtime-24.0.0.jar</div><div>lib/saxon-he-12.1.jar</div><div>lib/X3DJSAIL.4.0.full.jar</div></div><div><br></div><div>===========================================================</div><div>Once I get this working in Gradle, I will repost.</div><div><br></div><div>Note that I've not been able to load a JavaScript file from JavaScript in this scenario, so I've incorporated the X3DJSAIL-JavaScript interface directly in JavaScript code.</div><div><br></div><div>John</div><div><br></div><div><br></div></div></div></div></div></div></div>
</blockquote></div>