Index: /applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
===================================================================
--- /applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 16391)
+++ /applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 16392)
@@ -28,4 +28,5 @@
  * 
  * @author Jan Peter Stotz
+ * @author Stefan Zeller
  */
 public class OsmFileCacheTileLoader extends OsmTileLoader {
@@ -45,18 +46,38 @@
     protected long recheckAfter = FILE_AGE_ONE_DAY;
 
-    public OsmFileCacheTileLoader(TileLoaderListener map) {
+    /**
+     * 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) {
         super(map);
         String tempDir = System.getProperty("java.io.tmpdir");
         try {
-            if (tempDir == null)
+            if (cacheDir == null) {
+                if (tempDir == null) {
+                    throw new IOException("No temp directory set");
+                }
+                cacheDir = new File(tempDir, "JMapViewerTiles");
+            }
+            log.finest("Tile cache directory: " + cacheDir);
+            if (!cacheDir.exists() && !cacheDir.mkdirs()) {
                 throw new IOException();
-            File cacheDir = new File(tempDir, "JMapViewerTiles");
-            log.finest("Tile cache directory: " + cacheDir);
-            if (!cacheDir.exists() && !cacheDir.mkdirs())
-                throw new IOException();
+            }
             cacheDirBase = cacheDir.getAbsolutePath();
         } catch (Exception e) {
             cacheDirBase = "tiles";
         }
+    }
+    
+    /**
+     * Create a OSMFileCacheTileLoader with system property temp dir. 
+     * If not set an IOException will be thrown.
+     * @param map
+     */
+    public OsmFileCacheTileLoader(TileLoaderListener map) {
+        this(map, null);
     }
 
