Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interpretation of command line parameter

 
Jens M Mayer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jaspreet atwal
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wrap *.xml in quotes, like java test one "*.xml" three
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wrap *.xml in quotes, like java test one "*.xml" three

Isn't that precisely what I suggested?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic