Calling a Groovy function from Java

后端 未结 6 1691
猫巷女王i
猫巷女王i 2020-12-05 04:56

How do you call a function defined in a Groovy script file from Java?

Example groovy script:

def hello_world() {
   println \"Hello, world!\"
}
         


        
6条回答
  •  失恋的感觉
    2020-12-05 05:03

    You too can use the Bean Scripting Framework to embed any scripting language into your Java code. BSF give you the opportunity of integrate other languages, but is not native integration.

    If you are clearly focused to use Groovy the GroovyScriptEngine is the most complete solution.

    =)

提交回复
热议问题