I have download latest version of osmosis from http://wiki.openstreetmap.org/wiki/Osmosis#Downloading and mapsforge-map-writer-0.3.0-jar-with-dependencies.jar from https://code.google.com/p/mapsforge/downloads/list.
I copied mapsforge-map-writer-0.3.0-jar-with-dependencies.jar into
1- osmosis lib directory: osmosis-latest/lib/default
2- C:\Users\username\AppData\Roaming\Openstreetmap\Osmosis\Plugins
3- C:\Users\username\AppData\Local.openstreetmap\osmosis\plugins
I downloaded iran.osm file from geofabrik.de and then I created a batch file as below:
osmosis --rx file=iran.osm --mw file=iran.map bbox=35.574683,51.086426,35.833402,51.664581 type=hd
and I got this error:
SEVERE: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Cannot load JPF-plugin 'org.mapsforge.MapFileWriter' for extensionpoint 'Task' at org.openstreetmap.osmosis.core.TaskRegistrar.loadJPFPlugins(TaskRegistrar.java:186)
at org.openstreetmap.osmosis.core.TaskRegistrar.initialize(TaskRegistrar.java:88)
at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:81)
at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.java.plugin.PluginLifecycleException: plug-in org.mapsforge.map.mapfile-writer requires plug-in org.openstreetmap.osmosis.core.plugin.Core which is unknown or has incompatible version at org.java.plugin.standard.StandardPluginManager.checkPrerequisites(StandardPluginManager.java:460) at org.java.plugin.standard.StandardPluginManager.activatePlugin(StandardPluginManager.java:397)
at org.java.plugin.standard.StandardPluginManager.activatePlugin(StandardPluginManager.java:245)
at org.openstreetmap.osmosis.core.TaskRegistrar.loadJPFPlugins(TaskRegistrar.java:182)
... 12 more
PS: I switched back to osmosis 0.36 and I got this error:
SEVERE: Thread for task 1-rx failed
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Cannot represent 2147487728 as an integer.
at org.openstreetmap.osmosis.core.util.LongAsInt.longToInt(LongAsInt.java:33)
at org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData.init(CommonEntityData.java:142)
at org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData.<init>(CommonEntityData.java:74)
at org.openstreetmap.osmosis.core.domain.v0_6.Entity.<init>(Entity.java:61)
at org.openstreetmap.osmosis.core.domain.v0_6.Node.<init>(Node.java:71)
at org.openstreetmap.osmosis.xml.v0_6.impl.NodeElementProcessor.begin(NodeElementProcessor.java:87)
at org.openstreetmap.osmosis.xml.v0_6.impl.OsmHandler.startElement(OsmHandler.java:90)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.openstreetmap.osmosis.xml.v0_6.XmlReader.run(XmlReader.java:108)
at java.lang.Thread.run(Unknown Source)