JavaPackager icon indicating copy to clipboard operation
JavaPackager copied to clipboard

Linux Startup Script Does Not Quote Application Arguments

Open RedStoneMango opened this issue 5 months ago • 0 comments

Linux Startup Script Does Not Quote Application Arguments

Description:
In the current version of JavaPackager (v1.7.9), the generated Bash startup script for Linux does not properly quote application arguments. As a result, quoted argument lists are incorrectly split into multiple arguments when passed to the Java application, rather than being preserved as a single argument.

Affected Version:
Confirmed in v1.7.9

Steps to Reproduce:

  1. Write a Java app that prints the String[] args to the console.
  2. Build the app for Linux using JavaPackager.
  3. Run the app from the console with quoted arguments.

Expected Behavior:
Quoted arguments (e.g., "arg with spaces") should be one single element in the Java application's string array.

Actual Behavior:
Arguments are split at spaces, even within quoted strings, causing incorrect handling within the application's argument string array.


Suggested Fix

Update the script to properly preserve quoted arguments by using "$@" instead of $@. This ensures each argument is passed exactly as intended.

Modify the following lines in linux/startup.sh.vtl (around lines 84–88):

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

RedStoneMango avatar Jul 24 '25 09:07 RedStoneMango