In programmatic usage of CLI commands (in Java on Linux), would you
- rely on these commands being on the PATH, or
- specify the absolute path of each command in the code?
Different for “standard” commands, e.g. “ls”, vs. non-standard commands?
Addendum: By “in the code” I didn’t mean “hard-coded”. Having the the commands’ paths configurable would be of course the way to go.
Neither(!). I’d provide a configuration, which may be as trivial as a properties file.
e.g.
etc. The above is straightforward to implement, and very easy to change/override as required. I would be wary of relying on the PATH for all but the simplest scenarios.