Index: trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 13019)
+++ trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 13021)
@@ -11,8 +11,10 @@
 import java.awt.GraphicsEnvironment;
 import java.awt.GridBagLayout;
+import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Field;
 import java.net.Authenticator;
 import java.net.Inet6Address;
@@ -38,4 +40,5 @@
 import java.util.Objects;
 import java.util.Optional;
+import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.TreeSet;
@@ -90,4 +93,5 @@
 import org.openstreetmap.josm.data.osm.UserInfo;
 import org.openstreetmap.josm.data.osm.search.SearchMode;
+import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
 import org.openstreetmap.josm.data.preferences.sources.SourceType;
 import org.openstreetmap.josm.data.projection.ProjectionCLI;
@@ -148,4 +152,6 @@
 import org.openstreetmap.josm.plugins.PluginInformation;
 import org.openstreetmap.josm.spi.preferences.Config;
+import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;
+import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
 import org.openstreetmap.josm.tools.FontsManager;
 import org.openstreetmap.josm.tools.GBC;
@@ -926,5 +932,5 @@
         Main.pref.init(args.hasOption(Option.RESET_PREFERENCES));
         Config.setPreferencesInstance(Main.pref);
-        Config.setBaseDirectoriesProvider(Main.pref);
+        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance());
 
         args.getPreferencesToSet().forEach(Main.pref::put);
@@ -933,5 +939,11 @@
             I18n.set(Config.getPref().get("language", null));
         }
-        Main.pref.updateSystemProperties();
+        updateSystemProperties();
+        Main.pref.addPreferenceChangeListener(new PreferenceChangedListener() {
+            @Override
+            public void preferenceChanged(PreferenceChangeEvent e) {
+                updateSystemProperties();
+            }
+        });
 
         checkIPv6();
@@ -1069,4 +1081,36 @@
             Logging.info("Enabled EDT checker, wrongful access to gui from non EDT thread will be printed to console");
             RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
+        }
+    }
+
+    /**
+     * Updates system properties with the current values in the preferences.
+     */
+    private static void updateSystemProperties() {
+        if ("true".equals(Config.getPref().get("prefer.ipv6", "auto"))
+                && !"true".equals(Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"))) {
+            // never set this to false, only true!
+            Logging.info(tr("Try enabling IPv6 network, prefering IPv6 over IPv4 (only works on early startup)."));
+        }
+        Utils.updateSystemProperty("http.agent", Version.getInstance().getAgentString());
+        Utils.updateSystemProperty("user.language", Config.getPref().get("language"));
+        // Workaround to fix a Java bug. This ugly hack comes from Sun bug database: https://bugs.openjdk.java.net/browse/JDK-6292739
+        // Force AWT toolkit to update its internal preferences (fix #6345).
+        // Does not work anymore with Java 9, to remove with Java 9 migration
+        if (Utils.getJavaVersion() < 9 && !GraphicsEnvironment.isHeadless()) {
+            try {
+                Field field = Toolkit.class.getDeclaredField("resources");
+                Utils.setObjectsAccessible(field);
+                field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt"));
+            } catch (ReflectiveOperationException | RuntimeException e) { // NOPMD
+                // Catch RuntimeException in order to catch InaccessibleObjectException, new in Java 9
+                Logging.warn(e);
+            }
+        }
+        // Possibility to disable SNI (not by default) in case of misconfigured https servers
+        // See #9875 + http://stackoverflow.com/a/14884941/2257172
+        // then https://josm.openstreetmap.de/ticket/12152#comment:5 for details
+        if (Config.getPref().getBoolean("jdk.tls.disableSNIExtension", false)) {
+            Utils.updateSystemProperty("jsse.enableSNIExtension", "false");
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java	(revision 13019)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java	(revision 13021)
@@ -24,5 +24,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
-import org.openstreetmap.josm.data.Preferences;
 import org.openstreetmap.josm.data.ProjectionBounds;
 import org.openstreetmap.josm.data.coor.EastNorth;
@@ -30,4 +29,5 @@
 import org.openstreetmap.josm.data.coor.conversion.LatLonParser;
 import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
 import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.data.projection.Projections;
@@ -419,5 +419,5 @@
         Logging.setLogLevel(getLogLevel());
 
-        Config.setBaseDirectoriesProvider(new Preferences()); // for right-left-hand traffic cache file
+        Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()); // for right-left-hand traffic cache file
         Config.setPreferencesInstance(new MemoryPreferences());
         Config.getPref().putBoolean("mappaint.auto_reload_local_styles", false); // unnecessary to listen for external changes
