if you are reading the property file from main method you can simply access command line arguments via args[] array public static void main(String args[]) simple code like below might do
public static void main(String[] args) {
String splitChar="=";
try {
Map<String, String> propertyList = Files.readAllLines(Paths.get(args[0]))
.stream()
.map(String.class::cast)
.collect(Collectors.toMap(line -> line.split(splitChar)[0],
line -> line.split(splitChar)[1]));
System.out.println(propertyList);
} catch (IOException e) {
e.printStackTrace();
}
}
or else you can pass the path as vm option
java -Dfile.path={path to config file} {JavaClassFile to execute}
and you can get the path like below (from any where in your code)
System.getProperty("file.path")
and same as in main method above you can read the property file and put it into a HashMap which I prefer