Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8701655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:27:13+00:00 2026-06-13T02:27:13+00:00

I wrote a short shell script that takes in parameters, checks them (because they’re

  • 0

I wrote a short shell script that takes in parameters, checks them (because they’re “optional” and if they’re empty it sets default values), and them passes them to a Java class on the server. Basically, like so:

x=${2:-'Default'}
y=${3:-'Default Name Has Spaces'}
echo \"$x\"
echo \"$y\"
java -d64 -ms3G -mx3G -cp example.jar -Djava.security.policy=policy com.example.JavaClass $1 \"$x\" \"$y\"

However, when the shell makes the call to the Java class, I just get back that (if the above defaults are used) “argument Name is not recognized”.

With the escaped-quotes around the echo on lines 3 and 4, I see that the variables ARE set correctly and they’re echoed out like so: "Default" and "Default Name Has Spaces", yet even with the escaped quotes in the Java call, they seem to be passing as more than two arguments — it’s like they’re being passed as java -d64 -ms3G -mx3G -cp example.jar -Djava.security.policy=policy com.example.JavaClass $1 Default Default Name Has Spaces" which fails because the Java class only expects three total arguments.

Does anyone have any ideas as to why or how to make the arguments pass correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:27:15+00:00Added an answer on June 13, 2026 at 2:27 am

    The problem is that you’re quoting the ", which prevents it from quoting the arguments. Just remove the backslashes, and you should be set:

    x=${2:-'Default'}
    y=${3:-'Default Name Has Spaces'}
    echo "$x"
    echo "$y"
    java -d64 -ms3G -mx3G -cp example.jar -Djava.security.policy=policy com.example.JavaClass $1 "$x" "$y"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a script for a Linux bash shell. One line takes a list
To help me better understand lambda I wrote this short snippet that rotates and
I wrote a short Ruby script to profile MongoDB, just to see how its
I wrote a piped shell command that has multiple pipes in it that works
I'm a shell noob. I'm trying to write a simple script that'll take a
My assignment is to write a Unix shell script that asks the user for
I wrote this short program which has a tiny GUI. Its supposed to allow
I wrote a short bit of code to simply skip num_lines lines in an
I have a short question i have wrote this in java. Old code: class
I'm trying to write a short function that will let me quickly read in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.