Calling Python from Java through scripting engine (jython)?

前端 未结 2 1805
眼角桃花
眼角桃花 2020-12-28 09:35

I\'m trying to call Jython from a Java 6 application using javax.script:

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManag         


        
相关标签:
2条回答
  • 2020-12-28 10:24

    You'd probably have to register a ScriptEngineFactory for'python'

    0 讨论(0)
  • 2020-12-28 10:38

    You have to register your engine first.

    From: ScriptEngineManager.getEngineByName:

    [...] first searches for a ScriptEngineFactory that has been registered as a handle [...] Returns null if no such factory was found

    The user guide says to use it with JSR-223 you have to:

    As of Jython 2.5.1 an implementation of JSR 223 is bundled in jython.jar. Simply add jython to your CLASSPATH and ask for the python script engine.

    Did you do that already?

    EDIT About your comment: I think you should open a new question, you'll get better answers.

    0 讨论(0)
提交回复
热议问题