In order to run plugins written in Python, a Jython jar has to be on the classpath at startup time.
Here's how to start JOSM:$ java -classpath "/your/josm.jar:/your/jython.jar" org.openstreetmap.josm.gui.MainApplication
jython.jar
isn't included in the scripting plugin. The scripting plugin can download
it for you, just go to Scripting -> Configure..., or you can download it manually.
#
# A simple Python plugin which does basically nothing. It only prints
# a message when one of the callback methods is invoked by JOSM.
#
from org.openstreetmap.josm.plugins.scripting.python import JosmPythonPlugin
class HelloWorldPlugin(JosmPythonPlugin):
def onLoad(self):
print "onLoad: starting ..."
def onMapFrameChanged(self, oldFrame, newFrame):
print "onMapFrameChanged:"
print " old frame is: ", oldFrame
print " new frame is: ", newFrame
org.openstreetmap.josm.plugins.scripting.python.JosmPythonPlugin
You can create a jar file which includes the python source files required for a plugin.
If you have a plugin class MyPythonPlugin in the source file my_plugin.py, you can create a jar archive as follows:$ jar cvf my_plugin.jar my_plugin.py # add other python modules required by your plugin
my_plugin.jar
+-- my_plugin.py
+-- other_module.py
+-- my_package_1
+-- yet_another_module.py
+-- ....