9

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.

1
  • As you say, I want to know where and who does the expanding, and I want to control it. Sep 9, 2014 at 3:09

1 Answer 1

4

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! ;)

1
  • Thanks for the information Eric. I will definitely look into WildcardFileFilter. I don't have much (read any) experience writing Eclipse plugins, but I'll do some research to see if it is something I think I can handle. Thanks again.
    – crlane
    Jun 5, 2013 at 12:25

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.