I have the following code:
public class LoadProperty { public static final String property_file_location = System.getProperty("app.vmargs.propertyfile"); public static final String application-startup_mode = System.getProperty("app.vmargs.startupmode"); }
It reads "VM arguments" and assigns to variables.
Since a static final variable is only initialized when the class is loaded, how can I catch an exception if someone forgets to pass a parameter.
At the moment, when I use the variable 'property_file_location', an exception occurs in the following cases:
- If a value is present and the location is erroneous, a FileNotFound exception is thrown.
- If it is not initialized correctly (null), it throws a NullPointerException.
I need to handle the second case only at the time of initialization.
Sidimen is the case of the second variable.
Whole idea
- To initialize application configuration settings.
- If successfully initialized, continue.
- If not, warn the user and stop using.
source share