I set a JVM option with -Dpath.eai=C:\home\eai. Depending on where I call System.getProperty("path.eai"), I don't have the same result.
Call in a final class attribute's initialization
public static final String DIRECTORY = System.getProperty("path.eai");
private static String printDirectory() {
System.out.println("My directory is " + DIRECTORY);
}
==> DIRECTORY is null.
Call inside a method
private static final String EAI_PATH_PROPERTY = "path.eai";
public static final String DIRECTORY = getEaiPath();
private static String getEaiPath() {
String eaiPath = System.getProperty(EAI_PATH_PROPERTY);
return eaiPath;
}
private static String printDirectory() {
System.out.println("My directory is " + DIRECTORY);
}
==> DIRECTORY is C:\home\eai