Skip to content

Linux Startup Script Does Not Quote Application Arguments #470

@RedStoneMango

Description

@RedStoneMango

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions