diff --git a/core/launcher/src/main/java/org/phoebus/product/Launcher.java b/core/launcher/src/main/java/org/phoebus/product/Launcher.java index f1cf744d89..05b9bd88e1 100644 --- a/core/launcher/src/main/java/org/phoebus/product/Launcher.java +++ b/core/launcher/src/main/java/org/phoebus/product/Launcher.java @@ -27,16 +27,15 @@ @SuppressWarnings("nls") public class Launcher { - private static final String SETTINGS_OPTION = "-settings"; private static final String LOGGING_OPTION = "-logging"; private static final String DEFAULT_LOGGING_FILE="/logging.properties"; private static final String LOGGING_PROP = "java.util.logging.config.file"; - + public static void main(final String[] original_args) throws Exception { // First Handle arguments, potentially not even starting the UI - // settings and logging will define the phoebus.install value if not exist + // settings and logging will define the phoebus.install value if not exist final List args = new ArrayList<>(List.of(original_args)); - + //Handle logging first int indexOf = args.indexOf(LOGGING_OPTION); String loggingFilePath = null; @@ -60,22 +59,22 @@ public static void main(final String[] original_args) throws Exception { errorLoggingOption = "User logging file " + loggingFilePath + " not found"; } } - + //If no logging found use the default one if(loggingStream == null) { loggingFilePath = Launcher.class.getResource(DEFAULT_LOGGING_FILE).getFile(); loggingStream = Launcher.class.getResourceAsStream(DEFAULT_LOGGING_FILE); } - + //Load logging configuration LogManager.getLogManager().readConfiguration(loggingStream); final Logger logger = Logger.getLogger(Launcher.class.getPackageName()); logger.log(Level.CONFIG, "Loading logging configuration from " + loggingFilePath); - + if(errorLoggingOption != null) { logger.log(Level.WARNING, errorLoggingOption); } - + boolean showLaunchError = false; // Can't change default charset, but warn if it's not UTF-8. @@ -92,35 +91,21 @@ public static void main(final String[] original_args) throws Exception { logger.severe("Default charset is " + cs.displayName() + " instead of UTF-8."); logger.severe("Add -D\"file.encoding=UTF-8\" to java command line or JAVA_TOOL_OPTIONS"); } - - //Handle user settings.ini in order to get Locations informations - //as user home directory and phoebus folder name - //Install path will be set on call of install() - //Locations.initialize(); - indexOf = args.indexOf(SETTINGS_OPTION); - File site_settings = null; - if(indexOf > 0 && indexOf <= args.size()) { - String settingsFilePath = args.get(indexOf + 1); - site_settings = new File(settingsFilePath); - } - - if(site_settings == null || !site_settings.exists()) { - // Check for site-specific settings.ini bundled into distribution - // before potentially adding command-line settings. - String settingsError = site_settings != null ? site_settings.getAbsolutePath() + " not found" : "is not defined"; - logger.log(Level.WARNING, "Settings file " + settingsError); - site_settings = new File(Locations.install(), "settings.ini"); - } - - if(site_settings != null && site_settings.exists()) { - logger.info("Loading settings from " + site_settings.getAbsolutePath()); - FileInputStream fileInputStream = new FileInputStream(site_settings); + + Locations.initialize(); + // Check for site-specific settings.ini bundled into distribution + // before potentially adding command-line settings. + final File site_settings = new File(Locations.install(), "settings.ini"); + if (site_settings.canRead()) + { + logger.info("Loading bundled settings from " + site_settings.getAbsolutePath()); + final FileInputStream fileInputStream = new FileInputStream(site_settings); if (site_settings.getName().endsWith(".xml")) Preferences.importPreferences(fileInputStream); else PropertyPreferenceLoader.load(fileInputStream); } - + // Handle arguments, potentially not even starting the UI final Iterator iter = args.iterator(); int port = -1;