Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 16768)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 16769)
@@ -21,4 +21,5 @@
 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource.TileUpdate;
+import static org.openstreetmap.josm.tools.I18n.tr;
 
 /**
@@ -53,13 +54,18 @@
      * @param cacheDir
      */
-    public OsmFileCacheTileLoader(TileLoaderListener map, File cacheDir) {
+    public OsmFileCacheTileLoader(TileLoaderListener map, File cacheDir) throws SecurityException{
         super(map);
-        String tempDir = System.getProperty("java.io.tmpdir");
+        String tempDir = null;
         String userName = System.getProperty("user.name");
         try {
+            tempDir = System.getProperty("java.io.tmpdir");
+        } catch(SecurityException e) {
+            log.warning(tr("Failed to access system property ''{0}'' for security reasons. Exception was: {1}", "java.io.tmpdir", e.toString()));
+            throw e; // rethrow
+        }
+        try {
             if (cacheDir == null) {
-                if (tempDir == 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. 
@@ -70,7 +76,6 @@
             }
             log.finest("Tile cache directory: " + cacheDir);
-            if (!cacheDir.exists() && !cacheDir.mkdirs()) {
+            if (!cacheDir.exists() && !cacheDir.mkdirs())
                 throw new IOException();
-            }
             cacheDirBase = cacheDir.getAbsolutePath();
         } catch (Exception e) {
@@ -80,12 +85,13 @@
 
     /**
-     * Create a OSMFileCacheTileLoader with system property temp dir. 
+     * Create a OSMFileCacheTileLoader with system property temp dir.
      * If not set an IOException will be thrown.
      * @param map
      */
-    public OsmFileCacheTileLoader(TileLoaderListener map) {
+    public OsmFileCacheTileLoader(TileLoaderListener map) throws SecurityException {
         this(map, null);
     }
 
+    @Override
     public Runnable createTileLoaderJob(final TileSource source, final int tilex, final int tiley, final int zoom) {
         return new FileLoadJob(source, tilex, tiley, zoom);
@@ -120,6 +126,7 @@
             }
             tileCacheDir = new File(cacheDirBase, source.getName());
-            if (!tileCacheDir.exists())
+            if (!tileCacheDir.exists()) {
                 tileCacheDir.mkdirs();
+            }
             if (loadTileFromFile())
                 return;
@@ -200,6 +207,7 @@
                 tile.setImage(Tile.ERROR_IMAGE);
                 listener.tileLoadingFinished(tile, false);
-                if (input == null)
+                if (input == null) {
                     System.err.println("failed loading " + zoom + "/" + tilex + "/" + tiley + " " + e.getMessage());
+                }
             } finally {
                 tile.loading = false;
@@ -249,8 +257,9 @@
             do {
                 int read = input.read(buffer);
-                if (read >= 0)
+                if (read >= 0) {
                     bout.write(buffer, 0, read);
-                else
+                } else {
                     finished = true;
+                }
             } while (!finished);
             if (bout.size() == 0)
