Is there a way to make Eclipse expand wildcards in run configuration arguments? My class can handle the command line arguments passed to main(String[] args)
. From a normal shell (bash on my system), it is simple:
$java MyClass file*.txt
This runs my class with all files in the working directory that start with file
and end in .txt
supplied as command line args.
I would like to have this same behavior inside eclipse, but when I enter file*.txt
into the run configuration editor and run the program, the wildcard is not expanded. Rather than a list of files, the only arg recognized is the literal string file*.txt
.
This thread leads me to believe that it is possible or was once possible (at least on Windows - I'm running Mac OS X 10.6.8), but those folks were having the opposite problem of wildcards being expanded even when that behavior was not wanted.
In trying to solve this problem, I have tried using different environmental variables (i.e., ${string_prompt}, changed the working directory, looked through the Eclipse preferences and documentation, and googled relevant phrases but nothing has worked. Any suggestions or links to relevant information would be greatly appreciated.
It seems to be the desired behavior in Eclipse. Indeed, wildcard expansion in Windows is considered as a bug.
In contrast, the desired behavior in bash is what you expect, but Java (and hence your program) has no knowledge about it.
If you want your program to be smart and expand wildcards, you could use WildcardFileFilter
which is part of Apache Commons IO library.
Even better: you could write an Eclipse plugin that supports command line expansion. If you do so, please share! ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With