static protected void init(String commandLinePrefs) { // start by loading the defaults, in case something // important was deleted from the user prefs try { load(Base.getLibStream("preferences.txt")); } catch (Exception e) { Base.showError(null, _("Could not read default settings.\n" + "You'll need to reinstall Arduino."), e); } // check for platform-specific properties in the defaults String platformExt = "." + PConstants.platformNames[PApplet.platform]; int platformExtLength = platformExt.length(); Enumeration e = table.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); if (key.endsWith(platformExt)) { // this is a key specific to a particular platform String actualKey = key.substring(0, key.length() - platformExtLength); String value = get(key); table.put(actualKey, value); } } // clone the hash table defaults = (Hashtable) table.clone(); // other things that have to be set explicitly for the defaults setColor("run.window.bgcolor", SystemColor.control); // Load a prefs file if specified on the command line if (commandLinePrefs != null) { try { load(new FileInputStream(commandLinePrefs)); } catch (Exception poe) { Base.showError(_("Error"), I18n.format( _("Could not read preferences from {0}"), commandLinePrefs ), poe); } } else if (!Base.isCommandLine()) { // next load user preferences file preferencesFile = Base.getSettingsFile(PREFS_FILE); if (!preferencesFile.exists()) { // create a new preferences file if none exists // saves the defaults out to the file save(); } else { // load the previous preferences file try { load(new FileInputStream(preferencesFile)); } catch (Exception ex) { Base.showError(_("Error reading preferences"), I18n.format( _("Error reading the preferences file. " + "Please delete (or move)\n" + "{0} and restart Arduino."), preferencesFile.getAbsolutePath() ), ex); } } } }