<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>graaljs on Hi,I`m lan</title>
    <link>/tags/graaljs/</link>
    <description>Recent content in graaljs on Hi,I`m lan</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 05 Sep 2023 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="/tags/graaljs/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>java中调用javascript</title>
      <link>/post/run-javascript-on-the-java/</link>
      <pubDate>Tue, 05 Sep 2023 00:00:00 +0000</pubDate>
      
      <guid>/post/run-javascript-on-the-java/</guid>
      <description>说明 @Test public void testInvoke() throws ScriptException, NoSuchMethodException { ScriptEngine engine = getEngine(); String jsResult = &amp;quot;hello &amp;quot;; String param = &amp;quot;world&amp;quot;; String jsFunc = &amp;quot;function hello(param){return &#39;&amp;quot;+jsResult+&amp;quot;&#39; + &#39;&amp;quot;+param+&amp;quot;&#39; };&amp;quot;; engine.eval(jsFunc); Invocable in = (Invocable)engine; String result = (String) in.invokeFunction(&amp;quot;hello&amp;quot;,param); Assertions.assertEquals(jsResult+param,result); } public ScriptEngine getEngine(){ ScriptEngine engine = new ScriptEngineManager().getEngineByName(&amp;quot;graal.js&amp;quot;); Assertions.assertNotNull(engine); return engine; } 对应的关键依赖是: &amp;lt;properties&amp;gt; &amp;lt;graalvm-js.version&amp;gt;23.0.1&amp;lt;/graalvm-js.version&amp;gt; &amp;lt;/properties&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.graalvm.js&amp;lt;/groupId&amp;gt;</description>
    </item>
    
  </channel>
</rss>