jbang icon indicating copy to clipboard operation
jbang copied to clipboard

Support for running java -jar

Open dsyer opened this issue 1 year ago • 1 comments

As far as I can tell jbang always runs with -classpath, even if the resolved "script" is an executable jar. The logical thing to do would seem to be to spot (or have the user specify) the fact that it is executable, and just ignore the dependencies or not bother resolving them. Instead we get a long classpath with the executable jar at the start. Is there a reason for that?

Example from the TestRun test cases:

java -classpath /home/dsyer/.m2/repository/io/quarkus/quarkus-cli/1.9.0.Final/quarkus-cli-1.9.0.Final-runner.jar:...<long_list_of_dependencies>:/home/dsyer/.gradle/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging/3.3.2.Final/3789d00e859632e6c6206adc0c71625559e6e3b0/jboss-logging-3.3.2.Final.jar io.quarkus.runner.GeneratedMain

where

java -jar /home/dsyer/.m2/repository/io/quarkus/quarkus-cli/1.9.0.Final/quarkus-cli-1.9.0.Final-runner.jar

would have been just fine (and less prone to mismatched dependency resolution expectations between jbang and the jar author).

dsyer avatar Jun 22 '24 11:06 dsyer

Duplicates #1778?

dsyer avatar Jun 24 '24 07:06 dsyer

Using @fatjar works now with 0.117.0 (it skips the dependencies), so this issue is probably redundant. I.e.

$ jbang io.quarkus:quarkus-cli:1.8.1.Final@fatjar

dsyer avatar Aug 02 '24 06:08 dsyer