Das alles funktioniert gut, wenn es von Eclipse aus ausgeführt wird. Wenn ich die Anwendung jedoch mit jpackage unter macOS erstelle, schlägt der Rückruf von Python nach Java mit
fehl
Code: Select all
AttributeError: foreign object has no attribute 'msg'.
Im Java-Konstruktor:
Code: Select all
this.pythonContext = Context.newBuilder()
.allowAllAccess(true)
.option("python.PythonPath", pythonPath)
.build();
// load initialisation script source to execute
Source source = Source.newBuilder("python", new File(".....myscript.py")).build();
this.pythonContext.eval(source);
// create PAAFBuilder with reference to this JAAFBuilder for making callbacks
this.paafBuilder = this.pythonContext.getBindings("python").getMember("create").execute(this);
Code: Select all
@HostAccess.Export
public void msg(String msg) {
formatContext.getMessageContext().msg(msg);
System.out.println(msg);
}
Code: Select all
org.graalvm.polyglot
polyglot
${graalpy.version}
org.graalvm.polyglot
python
${graalpy.version}
pom
Mobile version