This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Windows cmd line args with wildcards

 
Carey Brown
Ranch Hand
Posts: 1378
16
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This shouldn't be this difficult. I want to pass a wildcard expression to my Java program WITHOUT having cmd.exe expand the argument to a list of files/directories. E.g. something like: java Program "*.java" where I want the asterisk-dot-java to come through as a single command line argument. I've tried the back-slash character and the caret to escape the asterisk, but no luck. What does Microsoft want from me?
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


C:\slop>java Test "*.java"
*.java

C:\slop>
 
Campbell Ritchie
Sheriff
Posts: 48635
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works just the same on Linux as on Windows.
 
Carey Brown
Ranch Hand
Posts: 1378
16
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I tried the code I get:
abc.java
xyz.java
(etc.)

Ah, there is a catch, IF there are actual java files in my current working directory I get the aforementioned list, ELSE IF there are NO java files in my CWD then I do get the literal "*.java" as my argument. I'm assuming this is a Microsoft'ism (XP). I never had this problem on UNIX.

P.S., mine was
 
Campbell Ritchie
Sheriff
Posts: 48635
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yesterday, I wrote:It works just the same on Linux as on Windows.
. . . and today I see it is different on Windows. No idea why. Sorry.
 
Rob Spoor
Sheriff
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:Ah, there is a catch, IF there are actual java files in my current working directory I get the aforementioned list, ELSE IF there are NO java files in my CWD then I do get the literal "*.java" as my argument. I'm assuming this is a Microsoft'ism (XP). I never had this problem on UNIX.

I also don't have that problem on my Windows 7 machine:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic