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

  • Home
  • SEARCH
  • 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 173221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:18:18+00:00 2026-05-11T13:18:18+00:00

In my Java command-line arguments, any characters after space get ignored. For example, java

  • 0

In my Java command-line arguments, any characters after space get ignored. For example,

java test.AskGetCampaignByName 'Dummy books' 

I get the first argument (args[0]) as ‘Dummy’ only. Single quotes also do not help. Is there a workaround/fix for this? Could it be because of my terminal settings?

My $TERM is xterm, and $LANG is ‘en_IN’.

  • 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. 2026-05-11T13:18:19+00:00Added an answer on May 11, 2026 at 1:18 pm

    The arguments are handled by the shell (I assume you are using Bash under Linux?), so any terminal settings should not affect this.

    Since you already have quoted the argument, it ought to work. The only possible explanation I can think of is if your java command is a wrapper script and messes up the escaping of the arguments when passing on to the real program. This is easy to do, or perhaps a bit hard to do correctly.

    A correct wrapper script should pass all its arguments on as ${1+'$@'}, and any other version is most likely a bug with regards to being able to handle embedded spaces properly. This is not uncommon to do properly, however also any occurrences of $2 or similar are troublesome and must be written as '$2' (or possibly ${2+'$2'}) in order to handle embedded spaces properly, and this is sinned against a lot.

    The reason for the not-so-intuitive syntax ${1+'$@'} is that the original $* joined all arguments as '$1 $2 $3 ...' which did not work for embedded spaces. Then '$@' was introduced that (correctly) expanded to '$1' '$2' '$3' ... for all parameters and if no parameters are given it should expand to nothing. Unfortunately some Unix vendor messed up and made '$@' expand to '' even in case of no arguments, and to work around this the clever (but not so readable) hack of writing ${1+'$@'} was invented, making '$@' only expand if parameter $1 is set (i.e. avoiding expansion in case of no arguments).

    If my wrapper assumption is wrong you could try to debug with strace:

    strace -o outfile -f -ff -F java test.AskGetCampaignByName 'Dummy books' 

    and find out what arguments are passed to execve. Example from running ‘strace /bin/echo '1 2' 3‘:

    execve('/bin/echo', ['/bin/echo', '1 2', '3'], [/* 93 vars */]) = 0 brk(0)                                  = 0x2400000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f420075b000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f420075a000 access('/etc/ld.so.preload', R_OK)      = -1 ENOENT (No such file or directory) open('/usr/lib64/alliance/lib/tls/x86_64/libc.so.6', O_RDONLY) = -1 ENOENT (No such file or directory) stat('/usr/lib64/alliance/lib/tls/x86_64', 0x7fff08757cd0) = -1 ENOENT (No such file or directory) open('/usr/lib64/alliance/lib/tls/libc.so.6', O_RDONLY) = -1 ENOENT (No such file or directory) ... 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 202k
  • Answers 202k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer After some guidance from "hcalves" I figured out the problem.… May 12, 2026 at 8:20 pm
  • Editorial Team
    Editorial Team added an answer From MSDN: FormsAuthenticationTicket.Expiration Property Gets the local date and time… May 12, 2026 at 8:20 pm
  • Editorial Team
    Editorial Team added an answer Since strings in Erlang are just a list() of integer()… May 12, 2026 at 8:20 pm

Related Questions

I would like to convert some HTML characters back to text using Java Standard
I have written a standalone Java application that I've packaged into a jar file
I'm writing a java app using eclipse which references a few external jars and
I am working on a security project at my university for open source software.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.