0

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.

3
  • I am not a java expert but can't you detect the environment from within the code and simply use an if/then statement? Commented Jun 6, 2013 at 18:15
  • 3
    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? Commented Jun 6, 2013 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! Commented Jun 6, 2013 at 19:53

1 Answer 1

2

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.