• Post Reply Bookmark Topic Watch Topic
  • New Topic

Windows cmd line args with wildcards

 
Carey Brown
Saloon Keeper
Posts: 2336
31
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • 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
Posts: 12373
40
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

C:\slop>
 
Campbell Ritchie
Marshal
Posts: 53161
124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works just the same on Linux as on Windows.
 
Carey Brown
Saloon Keeper
Posts: 2336
31
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • 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
Marshal
Posts: 53161
124
  • 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
Posts: 20831
68
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:
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!