jbangdev / jbang

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
https://jbang.dev
MIT License
1.37k stars 153 forks source link

JBang interactive option fails with `Unknown option: D` #947

Open sberyozkin opened 3 years ago

sberyozkin commented 3 years ago

In Quarkus, after doing quarkus create cli --jbang and then moving to the generated code-with-quarkus and running jbang --interactive src/main.java reports:

[jbang] You can run the main class `io.quarkus.runner.GeneratedMain` using: userMain(args)
Unknown option: D

Note adding a package declaration to src/main.java makes no difference

gastaldi commented 3 years ago

That's because the generated path uses jshell and it runs the following:

/home/ggastald/.sdkman/candidates/java/current/bin/jshell -Djava.util.logging.manager=org.jboss.logmanager.LogManager --class-path=/home/ggastald/.jbang/cache/jars/main.java.3ecc6e5945ddb5560d324568ec2caae63febafbf794206fbadf0ad4b82c8290c.jar:...

Which I think it is missing a -R or -J:

/home/ggastald/.sdkman/candidates/java/current/bin/jshell -R-Djava.util.logging.manager=org.jboss.logmanager.LogManager --class-path=/home/ggastald/.jbang/cache/jars/main.java.3ecc6e5945ddb5560d324568ec2caae63febafbf794206fbadf0ad4b82c8290c.jar:...
gastaldi commented 3 years ago

BTW removing the flag or putting the -R or -J prefix still fails the execution with:

Error:
package io.quarkus does not exist
int userMain(String[] args) { return io.quarkus.runner.GeneratedMain(args);}
                                     ^---------------^
|  Welcome to JShell -- Version 11.0.11
|  For an introduction type: /help intro

jshell> 
maxandersen commented 3 years ago

Is it missing users own jar ?

Btw. Even when we fix that we don't have a way to run quarkus non-blocking / in background so you can interact with it from jshell.

@stuartwdouglas you see a way to run quarkus in background and be able to interact with it from jshell ?

maxandersen commented 2 years ago

just saw https://github.com/bitterfox/JavaFXSupportsForJShell which use --execution flag on jshell to allow executoin on jfx thread....could be interesting to explore for quarkus too