Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 191254 - Command line parameters do not respect double quotes in windows
Command line parameters do not respect double quotes in windows
Status: RESOLVED WONTFIX
Product: projects
Classification: Unclassified
Component: Ant
7.0
PC Windows XP
: P3 (vote)
: TBD
Assigned To: Jesse Glick
issues@projects
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-10-22 13:04 UTC by tusharvjoshi
Modified: 2010-10-25 16:54 UTC (History)
0 users

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tusharvjoshi 2010-10-22 13:04:53 UTC
When I run a Java program with arguments the behaviour of NetBeans IDE is different than the command prompt in Windows XP.

Scenerio:

1) Create a basic Java application which prints all the arguments passed on command line
2) Build the project and run the class from command line like follows:

 java MyClass toto "has:\"toto titi\""

The output will be

 toto
 has:"toto titi"

The double quotes are escaped properly and the Java program received only two arguments

Now set this same arguments in NetBeans Project properties Run node Arguments text box

Run the project from NetBeans IDE and the output is as follows:

 toto
 has:\titi
 tutu\

The Java program received three parameters and all the quotes are eaten (missing)

I tried different workarounds in the arguments text box but cannot find any workaround to pass double quotes to the Java program in Windows XP

[Same program in Max OS X has different behavior and I was able to pass the parameters as two parameters by configuring the argument text box as 

 toto 'has:"toto titi"' 

that is enclosed in single quotes
Comment 1 Tomas Zezula 2010-10-25 16:05:16 UTC
The value is just passed to Ant's java as arg line.
Comment 2 Tomas Zezula 2010-10-25 16:12:40 UTC
 Ant will try to split the command line in a way similar to what a (Unix) shell would do.
Comment 3 tusharvjoshi 2010-10-25 16:45:41 UTC
I understand that the arguments are passed to the ant target as arg element.
My point is the behavior shown by Windows Command Prompt and the NetBeans IDE shall be same on Windows.

This may be a bug with the ANT component NetBeans IDE is using, but for the user the perception is what they are getting from command line is not available through NetBeans IDE GUI.

It will also be worthwhile to think about any workaround, any escape sequence which can be passed through the NetBeans IDE GUI to achieve this somehow.  

This may be an issue with the ANT component, in that case still we will have to find out workaround for ANT issue, as NetBeans IDE internally uses ANT.

with regards
Tushar Joshi, Nagpur
Comment 4 Jesse Glick 2010-10-25 16:54:32 UTC
Handling metacharacters in Unix command-line parsing is difficult, and Windows behaves completely differently. The best we can do is pass <arg line="${something}"/> to Ant, which tries to parse this out as best it can, but in general passing metachars such as spaces will not work well when they have to be encoded and then decoded this way. Configuring a variable-length list of arguments as separate properties is not an option because (without using <script> or specialized tasks) it is not possible for an Ant script to pass execution args of a statically unknown length except by line="...".

If your app really needs specialized CLI arguments, it is best to override the run target in build.xml and pass them in as <arg value="..."/>, which bypasses the escaping/unescaping system. (At least on Unix; I have no idea what Windows will do.)

Safer is probably to have a config file in a format of your choice with detailed information, and just pass the location of this config file to the app.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo