For a prototype that is running in an isolated environment I was in need of an offline OpenStreetMap component for Java. Of all the awesomeness that OpenStreetMap does provide this was not one of them.
Luckily I’m not the person that is afraid of some quick hack-n-slash work. After inspecting the code of JMapViewer which is released under GPL by OpenStreetMap I quickly found out to add support for OpenStreetMap by creating an extension of AbstractOsmTileSource. A stunning 29 lines of code later and offline support was ready. I put it up on GitHub in case anyone is interested in it as well: https://github.com/balloob/JMapViewer
I put up a full copy of their SVN-repository with my offline-class included. Just the class can be found here.
How to use it:
JMapViewer map = new JMapViewer(); map.setTileSource(new OfflineOsmTileSource("file:///path/to/tiles/",1,9));
To download the Open Streetmap tiles to your computer you can use jTileDownloader.
Note that jTileDownloader 0.6 requires Java 7. It will not throw an error when an older JRE is used untill you click the download button.
As of this writing (August 2, 2012) Apple has not released Java 7 for OS X yet.