Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a Java Project, and I wrote a small plug-in to the existing project. I wrote it on my Mac(dev), QA is on Windows and Prod is on Unix.

In the code I make specific API calls to a different program. On my mac though I'm just reading in a file. In Dev it is using windows file path to execute an external programs CLI. Prod will be the same.

I'm aware of property files, should I use a property file for this to quickly switch environments.

At the moment it is just a lot of commenting/uncommenting to get everything up and running.

share|improve this question
I am not a java expert but can't you detect the environment from within the code and simply use an if/then statement? – Mike Jun 6 '13 at 18:15
It's unfortunate that the code inside any if (EnvironmentIsProd){..} statements are never run before being seen by customers. Is this a case for Dependency Injection? – Dan Pichelman Jun 6 '13 at 18:24
I guess you meant "in QA [environment] it is using windows file path ...". And how can your program do "the same" in Prod - are there any "windows file paths" in your Unix environment? And what do you mean by "windows file path"? A hardcoded path in your application? The "path" environment variable? Please edit your question and make it a little bit more precise! – Doc Brown Jun 6 '13 at 19:53
up vote 2 down vote accepted

Best solution IMHO would be to completely avoid making any differences between those 3 environments in your Java program's code. So why don't you just provide a more or less simple command line program in your Mac environment (which is in fact a Unix environment, too) which takes exactly the same parameters as the external programs in the other 2 environments, and returns results in a compatible form? The path to this program should be configured by some kind of configuration file, outside of your Java source code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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