[Logo]
Forums Register Login
Windows cmd line args with wildcards
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?


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

C:\slop>
It works just the same on Linux as on Windows.
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
 
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.
 
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:
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 23, 2017 17:35:51.