fvarrui / JavaPackager

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
GNU General Public License v3.0
1.07k stars 134 forks source link

Linux startup.sh.vlt template error #203

Closed AstroPixelProcessor closed 1 year ago

AstroPixelProcessor commented 2 years ago

I'm submitting a…

Short description of the issue/suggestion:

With the current startup.sh.vlt template, once you stop the application when started from the Linux commandline, you will see an error:

exit: 0PK: numeric argument required

What is the expected behavior?

application should exit without this Bash script error

What is the current behavior?

Errors with this error

Please tell us about your environment:

Solution : alter the end of startup.sh.vlt template from

if ($info.administratorRequired)

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GDKBACKEND=x11 $JAVA $JVMDefaultOptions -cp $JVMClassPath ${info.mainClass} $@

else

$JAVA $JVMDefaultOptions -cp $JVMClassPath ${info.mainClass} $@

end

exit 0

to

if ($info.administratorRequired)

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GDKBACKEND=x11 $JAVA $JVMDefaultOptions -cp $JVMClassPath ${info.mainClass} $@

else

$JAVA $JVMDefaultOptions -cp $JVMClassPath ${info.mainClass} $@

end

STATUS=$? if [ $STATUS -eq 0 ]; then exit 0 else exit 1 fi

fvarrui commented 2 years ago

Hi @AstroPixelProcessor! Thanks for opening this issue and propose a solution ... I have to do some more research about this problem, as it's a bit weird; at least, I can understand what's happening.

JavaPackager creates binaries for Linux concatenating startup.sh + runnable.jar, and then setting execution permissions in the resulting file (the binary).

It seems that the last line in the startup script (exit 0) has no separation from the merged JAR file (\n after exit 0 is being removed before both files are merged) ... are you using a customized startup script template for Linux?

fvarrui commented 2 years ago

Hi @AstroPixelProcessor! Sorry, but I'm not able to reproduce your issue.

fvarrui commented 2 years ago

Hi @AstroPixelProcessor! Can you give me with an example in order to test it?

fvarrui commented 2 years ago

Hi @AstroPixelProcessor! I was reviewing old issues and came back to this one.

I decided to apply the next change:

#if ($info.administratorRequired)
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GDKBACKEND=x11 $JAVA $JVMDefaultOptions -cp $JVMClassPath ${info.mainClass} $@
#else
$JAVA $JVMDefaultOptions -cp $JVMClassPath ${info.mainClass} $@
#end
exit $?

This way, the exit code returned by java is also returned by the BASH script, instead of always returning a 0.

AstroPixelProcessor commented 2 years ago

Hi @fvarrui,

Apologies for the silence from my side. I will get back to you tomorrow about this one ;-)

I have several other suggestions for the packager and will let you know about it as well after reviewing/studying the latest commits of course.

Mabula

fvarrui commented 1 year ago

Hi @AstroPixelProcessor! I close this issue due to lack of activity. If this problem persists, please reopen it. Thanks!