Index: /trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 13768)
+++ /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 13769)
@@ -7,4 +7,5 @@
 import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
+import java.awt.GraphicsEnvironment;
 import java.io.File;
 import java.io.IOException;
@@ -552,11 +553,13 @@
                 Logging.warn(tr("Failed to initialize preferences. Preference directory ''{0}'' is not a directory.",
                         prefDir.getAbsoluteFile()));
-                JOptionPane.showMessageDialog(
-                        Main.parent,
-                        tr("<html>Failed to initialize preferences.<br>Preference directory ''{0}'' is not a directory.</html>",
-                                prefDir.getAbsoluteFile()),
-                        tr("Error"),
-                        JOptionPane.ERROR_MESSAGE
-                );
+                if (!GraphicsEnvironment.isHeadless()) {
+                    JOptionPane.showMessageDialog(
+                            Main.parent,
+                            tr("<html>Failed to initialize preferences.<br>Preference directory ''{0}'' is not a directory.</html>",
+                                    prefDir.getAbsoluteFile()),
+                            tr("Error"),
+                            JOptionPane.ERROR_MESSAGE
+                    );
+                }
                 return;
             }
@@ -565,11 +568,13 @@
                 Logging.warn(tr("Failed to initialize preferences. Failed to create missing preference directory: {0}",
                         prefDir.getAbsoluteFile()));
-                JOptionPane.showMessageDialog(
-                        Main.parent,
-                        tr("<html>Failed to initialize preferences.<br>Failed to create missing preference directory: {0}</html>",
-                                prefDir.getAbsoluteFile()),
-                        tr("Error"),
-                        JOptionPane.ERROR_MESSAGE
-                );
+                if (!GraphicsEnvironment.isHeadless()) {
+                    JOptionPane.showMessageDialog(
+                            Main.parent,
+                            tr("<html>Failed to initialize preferences.<br>Failed to create missing preference directory: {0}</html>",
+                                    prefDir.getAbsoluteFile()),
+                            tr("Error"),
+                            JOptionPane.ERROR_MESSAGE
+                    );
+                }
                 return;
             }
@@ -591,11 +596,13 @@
         } catch (IOException e) {
             Logging.error(e);
-            JOptionPane.showMessageDialog(
-                    Main.parent,
-                    tr("<html>Failed to initialize preferences.<br>Failed to reset preference file to default: {0}</html>",
-                            getPreferenceFile().getAbsoluteFile()),
-                    tr("Error"),
-                    JOptionPane.ERROR_MESSAGE
-            );
+            if (!GraphicsEnvironment.isHeadless()) {
+                JOptionPane.showMessageDialog(
+                        Main.parent,
+                        tr("<html>Failed to initialize preferences.<br>Failed to reset preference file to default: {0}</html>",
+                                getPreferenceFile().getAbsoluteFile()),
+                        tr("Error"),
+                        JOptionPane.ERROR_MESSAGE
+                );
+            }
             return;
         }
@@ -606,12 +613,14 @@
             Logging.error(e);
             File backupFile = new File(prefDir, "preferences.xml.bak");
-            JOptionPane.showMessageDialog(
-                    Main.parent,
-                    tr("<html>Preferences file had errors.<br> Making backup of old one to <br>{0}<br> " +
-                            "and creating a new default preference file.</html>",
-                            backupFile.getAbsoluteFile()),
-                    tr("Error"),
-                    JOptionPane.ERROR_MESSAGE
-            );
+            if (!GraphicsEnvironment.isHeadless()) {
+                JOptionPane.showMessageDialog(
+                        Main.parent,
+                        tr("<html>Preferences file had errors.<br> Making backup of old one to <br>{0}<br> " +
+                                "and creating a new default preference file.</html>",
+                                backupFile.getAbsoluteFile()),
+                        tr("Error"),
+                        JOptionPane.ERROR_MESSAGE
+                );
+            }
             Main.platform.rename(preferenceFile, backupFile);
             try {
