Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java	(revision 24988)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java	(revision 24989)
@@ -8,4 +8,5 @@
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.io.IOException;
 
 import javax.swing.JButton;
@@ -61,6 +62,11 @@
             }
         });
-        JComboBox tileLoaderSelector = new JComboBox(new TileLoader[] { new OsmFileCacheTileLoader(map),
-                new OsmTileLoader(map) });
+        JComboBox tileLoaderSelector;
+        try {
+            tileLoaderSelector = new JComboBox(new TileLoader[] { new OsmFileCacheTileLoader(map),
+                    new OsmTileLoader(map) });
+        } catch (IOException e) {
+            tileLoaderSelector = new JComboBox(new TileLoader[] { new OsmTileLoader(map) });
+        }
         tileLoaderSelector.addItemListener(new ItemListener() {
             public void itemStateChanged(ItemEvent e) {
Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 24988)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 24989)
@@ -54,13 +54,5 @@
     protected long recheckAfter = FILE_AGE_ONE_DAY;
 
-    /**
-     * Create a OSMFileCacheTileLoader with given cache directory.
-     * If cacheDir is <code>null</code> the system property temp dir
-     * is used. If not set an IOException will be thrown.
-     * @param map
-     * @param cacheDir
-     */
-    public OsmFileCacheTileLoader(TileLoaderListener map, File cacheDir) throws SecurityException {
-        super(map);
+    public static File getDefaultCacheDir() throws SecurityException {
         String tempDir = null;
         String userName = System.getProperty("user.name");
@@ -74,22 +66,32 @@
         }
         try {
-            if (cacheDir == null) {
-                if (tempDir == null)
-                    throw new IOException("No temp directory set");
-                String subDirName = "JMapViewerTiles";
-                // On Linux/Unix systems we do not have a per user tmp directory.
-                // Therefore we add the user name for getting a unique dir name.
-                if (userName != null && userName.length() > 0) {
-                    subDirName += "_" + userName;
-                }
-                cacheDir = new File(tempDir, subDirName);
-            }
-            log.finest("Tile cache directory: " + cacheDir);
-            if (!cacheDir.exists() && !cacheDir.mkdirs())
-                throw new IOException();
-            cacheDirBase = cacheDir.getAbsolutePath();
+            if (tempDir == null)
+                throw new IOException("No temp directory set");
+            String subDirName = "JMapViewerTiles";
+            // On Linux/Unix systems we do not have a per user tmp directory.
+            // Therefore we add the user name for getting a unique dir name.
+            if (userName != null && userName.length() > 0) {
+                subDirName += "_" + userName;
+            }
+            File cacheDir = new File(tempDir, subDirName);
+            return cacheDir;
         } catch (Exception e) {
-            cacheDirBase = "tiles";
-        }
+        }
+        return null;
+    }
+
+    /**
+     * Create a OSMFileCacheTileLoader with given cache directory.
+     * If cacheDir is not set or invalid, IOException will be thrown.
+     * @param map
+     * @param cacheDir
+     */
+    public OsmFileCacheTileLoader(TileLoaderListener map, File cacheDir) throws IOException  {
+        super(map);
+        if (cacheDir == null || (!cacheDir.exists() && !cacheDir.mkdirs()))
+            throw new IOException("Cannot access cache directory");
+
+        log.finest("Tile cache directory: " + cacheDir);
+        cacheDirBase = cacheDir.getAbsolutePath();
     }
 
@@ -99,6 +101,6 @@
      * @param map
      */
-    public OsmFileCacheTileLoader(TileLoaderListener map) throws SecurityException {
-        this(map, null);
+    public OsmFileCacheTileLoader(TileLoaderListener map) throws SecurityException, IOException {
+        this(map, getDefaultCacheDir());
     }
 
