graalpython-java-example icon indicating copy to clipboard operation
graalpython-java-example copied to clipboard

jar package is not runnable

Open paulvi opened this issue 4 years ago • 2 comments

% mvn package

% java -jar target/PygalExample-1.0-SNAPSHOT.jar
no main manifest attribute, in target/PygalExample-1.0-SNAPSHOT.jar

that is fixed with PR #5 ,

however there is next issue ModuleNotFoundError: No module named 'pygal'

% java -jar target/PygalExample-1.0-SNAPSHOT.jar
Exception in thread "main" ModuleNotFoundError: No module named 'pygal'
        at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:353)
        at com.oracle.example.javapython.Main.createPygalRenderer(Main.java:65)
        at com.oracle.example.javapython.Main.main(Main.java:27)

that is graal module resolution does not work for release jar, even though it should

paulvi avatar Jul 15 '21 11:07 paulvi

sorry, but packaging as a single jar is not part of this example :) that is quite a bit more involved

timfel avatar Jul 15 '21 12:07 timfel

yes, it is much more work

I guess the example code is doing it right by reading py source as stream

InputStreamReader code = new InputStreamReader(Main.class.getClassLoader().getResourceAsStream(SOURCE_FILE_NAME));
        Source source;
        try {
            source = Source.newBuilder(PYTHON, code, SOURCE_FILE_NAME).build();

But because of py dependencies are complicated matter, this scenario maybe is not yet supported in GraalVM 21.1.0 version

paulvi avatar Jul 15 '21 12:07 paulvi