Index: trunk/src/org/openstreetmap/josm/data/preferences/JosmBaseDirectories.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/preferences/JosmBaseDirectories.java	(revision 13775)
+++ trunk/src/org/openstreetmap/josm/data/preferences/JosmBaseDirectories.java	(revision 13776)
@@ -5,4 +5,5 @@
 import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
+import java.awt.GraphicsEnvironment;
 import java.io.File;
 
@@ -69,10 +70,12 @@
             if (createIfMissing && !preferencesDir.exists() && !preferencesDir.mkdirs()) {
                 Logging.warn(tr("Failed to create missing preferences directory: {0}", preferencesDir.getAbsoluteFile()));
-                JOptionPane.showMessageDialog(
-                        Main.parent,
-                        tr("<html>Failed to create missing preferences directory: {0}</html>", preferencesDir.getAbsoluteFile()),
-                        tr("Error"),
-                        JOptionPane.ERROR_MESSAGE
-                );
+                if (!GraphicsEnvironment.isHeadless()) {
+                    JOptionPane.showMessageDialog(
+                            Main.parent,
+                            tr("<html>Failed to create missing preferences directory: {0}</html>", preferencesDir.getAbsoluteFile()),
+                            tr("Error"),
+                            JOptionPane.ERROR_MESSAGE
+                    );
+                }
             }
         } catch (SecurityException e) {
@@ -100,10 +103,12 @@
             if (createIfMissing && !userdataDir.exists() && !userdataDir.mkdirs()) {
                 Logging.warn(tr("Failed to create missing user data directory: {0}", userdataDir.getAbsoluteFile()));
-                JOptionPane.showMessageDialog(
-                        Main.parent,
-                        tr("<html>Failed to create missing user data directory: {0}</html>", userdataDir.getAbsoluteFile()),
-                        tr("Error"),
-                        JOptionPane.ERROR_MESSAGE
-                );
+                if (!GraphicsEnvironment.isHeadless()) {
+                    JOptionPane.showMessageDialog(
+                            Main.parent,
+                            tr("<html>Failed to create missing user data directory: {0}</html>", userdataDir.getAbsoluteFile()),
+                            tr("Error"),
+                            JOptionPane.ERROR_MESSAGE
+                    );
+                }
             }
         } catch (SecurityException e) {
@@ -136,10 +141,12 @@
             if (createIfMissing && !cacheDir.exists() && !cacheDir.mkdirs()) {
                 Logging.warn(tr("Failed to create missing cache directory: {0}", cacheDir.getAbsoluteFile()));
-                JOptionPane.showMessageDialog(
-                        Main.parent,
-                        tr("<html>Failed to create missing cache directory: {0}</html>", cacheDir.getAbsoluteFile()),
-                        tr("Error"),
-                        JOptionPane.ERROR_MESSAGE
-                );
+                if (!GraphicsEnvironment.isHeadless()) {
+                    JOptionPane.showMessageDialog(
+                            Main.parent,
+                            tr("<html>Failed to create missing cache directory: {0}</html>", cacheDir.getAbsoluteFile()),
+                            tr("Error"),
+                            JOptionPane.ERROR_MESSAGE
+                    );
+                }
             }
         } catch (SecurityException e) {
