permaculture playing cards*
The moose likes Beginning Java and the fly likes interpretation of command line parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "interpretation of command line parameter" Watch "interpretation of command line parameter" New topic
Author

interpretation of command line parameter

Jens M Mayer
Greenhorn

Joined: Aug 27, 2007
Posts: 4
Hi folks,

Look at this tiny little class:



Invocation with the following parameters:

one two three

will generate the output:

argument0ne
argument1:two
argument2:three

Nothing special so far.

Now I change the parameters to:

one *.xml three

The working directory contains two xml-files: abc.xml and xyz.xml

The output is:
argument0ne
argument1:abc.xml
argument2:xyz.xml
argument3:three

Wow! The java-command automatically expands filenames containing wildcards!
Nice feature....but I want the output look like this:

argument0ne
argument1:*.xml
argument2:three

Any ideas ?

Jens
[ April 21, 2008: Message edited by: Jens M Mayer ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
It's not Java doing this, it's the shell you're typing this in. I think surrounding the parameters with double quotes (like "*.xml") will prevent it from happening. The specifics may depend on the shell, though.


Ping & DNS - my free Android networking tools app
jaspreet atwal
Ranch Hand

Joined: Sep 05, 2007
Posts: 52
wrap *.xml in quotes, like java test one "*.xml" three


Still Learing..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
wrap *.xml in quotes, like java test one "*.xml" three

Isn't that precisely what I suggested?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interpretation of command line parameter
 
Similar Threads
passing parameters through url
what does (String[ ] args) mean?
Sending any string via cmd. code given
arguments by using code
Nested For Loops - understanding them