I have two projects. One at location a and other at b.
Project a needs to load the conf file from project b's directory. I can't hardcode the path for file which is located in b's directory because If I run this on different machine everymachine's username will be different and path can be different as well.
So I want to do is, everyone sets their conf file path as environment varibale in .bashrc. That way I want to use exported variable path in my java code. Now the question is how do I do that?
Following is something similar to what I want to do:
I have one varibale stored in my system at .bashrc as follows:
export variableName1=~/path_to_file
Now I want to use this variable in java while loading the config file as follows:
Config config = ConfigFactory.parseFile(new File("${variableName1}/path_to_file"));
How do I do that?
I tried getting the value of variableName1 as follows:
String value = System.getProperty("variableName1");
OR
String value = System.getenv("variableName1");
But this returns null value only.
That's an environment variable so is accessed with
String myDirectory = System.getenv("variableName1");