Index: applications/editors/josm/plugins/toms/src/toms/Toms.java
===================================================================
--- applications/editors/josm/plugins/toms/src/toms/Toms.java	(revision 23109)
+++ applications/editors/josm/plugins/toms/src/toms/Toms.java	(revision 23119)
@@ -8,6 +8,25 @@
 
 import java.awt.event.KeyEvent;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
 
 import javax.swing.JMenuItem;
@@ -23,4 +42,6 @@
 import toms.dialogs.SmpDialogAction;
 import toms.plug.PluginApp;
+import toms.plug.ifc.Pluggable;
+import toms.plug.util.PluginLoader;
 import toms.seamarks.SeaMark;
 
@@ -48,7 +69,76 @@
 		SmpDialog.setUserHome(userHome);
 		Smp.setEnabled(false);
+
+		File pluginDir = Main.pref.getPluginsDirectory();
+		String pluginDirName = pluginDir.getAbsolutePath();
+		File tplug = new File(pluginDirName + "/tplug");
+		if(!tplug.exists()) tplug.mkdir();
 		
-		PluginApp.runPlugins();
+		// build ifc.jar from toms.jar
+		JarEntry ent = null;
+		BufferedInputStream inp = null;
+		String entName = null;
+		byte[] buffer = new byte[16384];
+		int len;
+
+		try {
+			JarFile file = new JarFile(pluginDirName  + "/toms.jar");			
+			FileOutputStream fos = new FileOutputStream(pluginDirName + "/tplug/ifc.jar");			
+			JarOutputStream jos = new JarOutputStream(fos);
+			BufferedOutputStream oos = new BufferedOutputStream( jos);
+
+			ent = file.getJarEntry("toms/plug/ifc/Pluggable.class");
+			inp = new BufferedInputStream(file.getInputStream( ent ));
+			entName = ent.getName();
+
+			jos.putNextEntry(new JarEntry(entName));
+			
+		    while ((len = inp.read(buffer)) > 0) {
+		    	oos.write(buffer, 0, len);
+            }
+
+		    oos.flush();
+		    inp.close();
+	    
+		    ent = file.getJarEntry("toms/plug/ifc/PluginManager.class");
+		    inp = new BufferedInputStream(file.getInputStream( ent ));
+		    entName = ent.getName();
+		    jos.putNextEntry(new JarEntry(entName));
+		    
+		    while ((len = inp.read(buffer)) > 0) {
+		    	oos.write(buffer, 0, len);
+            }
+
+			oos.flush();
+			oos.close();
+		    fos.flush();
+		    fos.close();
+		    inp.close();
+			
+		} catch (Exception e) {
+			e.printStackTrace();
+		} 
+		
+		
+		// add ifc.jar to classpath (josm need this archive, or perhaps only the interface)
+		File f = new java.io.File(pluginDirName + "/tplug/ifc.jar");
+		ClassLoader myClassLoader = Thread.currentThread().getContextClassLoader();
+
+		try {
+			Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
+			addUrlMethod.setAccessible(true);
+			addUrlMethod.invoke(myClassLoader, f.toURI().toURL());
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		
+		try {
+			PluginApp.runPlugins();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
 	}
+
 
 	@Override
Index: applications/editors/josm/plugins/toms/src/toms/plug/PluginApp.java
===================================================================
--- applications/editors/josm/plugins/toms/src/toms/plug/PluginApp.java	(revision 23109)
+++ applications/editors/josm/plugins/toms/src/toms/plug/PluginApp.java	(revision 23119)
@@ -2,14 +2,36 @@
 
 import java.io.File;
+import java.io.IOException;
 import java.util.List;
 
+import org.openstreetmap.josm.Main;
+
+
 import toms.plug.ifc.Pluggable;
+import toms.plug.ifc.PluginManager;
 import toms.plug.util.PluginLoader;
 
 public class PluginApp {
 	
-	public static void runPlugins() {
-		List<Pluggable> plugins = PluginLoader.loadPlugins(new File("./tplug"));
-		System.out.println("hello world");
+	public static void runPlugins() throws IOException {
+		String pluginDirName = Main.pref.getPluginsDirectory().getAbsolutePath();
+
+		List<Pluggable> plugins = PluginLoader.loadPlugins(new File(pluginDirName + "/tplug"));
+
+		if(plugins == null) return;
+		
+		PluginManager manager = new PluginManagerImpl();
+		
+		for(Pluggable p : plugins) p.setPluginManager(manager);
+		for(Pluggable p : plugins) p.start();
+		
+		// wait
+		try {
+			Thread.sleep(10000);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		
+		for(Pluggable p: plugins) p.stop();
 	}
 
Index: applications/editors/josm/plugins/toms/src/toms/plug/util/PluginLoader.java
===================================================================
--- applications/editors/josm/plugins/toms/src/toms/plug/util/PluginLoader.java	(revision 23109)
+++ applications/editors/josm/plugins/toms/src/toms/plug/util/PluginLoader.java	(revision 23119)
@@ -2,13 +2,104 @@
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
 
 import toms.plug.ifc.Pluggable;
 
+
 public class PluginLoader {
 
-	public static List<Pluggable> loadPlugins(File file) {
-		System.out.println("Hier ist der PluginLoader");
-		return null;
+	public static List<Pluggable> loadPlugins(File plugDir) throws IOException {
+		File[] plugJars = plugDir.listFiles(new JARFileFilter());
+		ClassLoader cl = new URLClassLoader(PluginLoader.fileArrayToURLArray(plugJars));
+		
+		if(cl == null) return null;
+		
+		List<Class<Pluggable>> plugClasses = PluginLoader.extractClassesFromJARs(plugJars, cl);
+		
+		return PluginLoader.createPluggableObjects(plugClasses);
+	}
+
+	private static List<Pluggable> createPluggableObjects(List<Class<Pluggable>> pluggables) {
+		List<Pluggable> plugs = new ArrayList<Pluggable>(pluggables.size());
+		for(Class<Pluggable> plug : pluggables) {
+			try {
+				plugs.add(plug.newInstance());
+			} catch (InstantiationException e) {
+				System.err.println("Can't instantiate plugin: " + plug.getName());
+				e.printStackTrace();
+			} catch (IllegalAccessException e) {
+				System.err.println("IllegalAccess for plugin: " + plug.getName());
+				e.printStackTrace();
+			}
+		}
+		
+		return plugs;
+
+	}
+
+	private static List<Class<Pluggable>> extractClassesFromJARs(	File[] jars, ClassLoader cl) throws FileNotFoundException, IOException {
+		List<Class<Pluggable>> classes = new ArrayList<Class<Pluggable>>();
+		
+		for(File jar : jars) {
+			classes.addAll(PluginLoader.extractClassesFromJAR(jar, cl));
+		}
+
+		return classes;
+	}
+
+	@SuppressWarnings("unchecked")
+	private static Collection<? extends Class<Pluggable>> extractClassesFromJAR(File jar, ClassLoader cl) throws FileNotFoundException, IOException {
+		List<Class<Pluggable>> classes = new ArrayList<Class<Pluggable>>();
+		JarInputStream jaris = new JarInputStream(new FileInputStream(jar));
+		JarEntry ent = null;
+		
+		while ((ent = jaris.getNextJarEntry()) != null) {
+			String entName = ent.getName(); //.toLowerCase();
+			
+			if (entName.endsWith(".class")) {
+				try {
+					Class<?> cls = cl.loadClass(entName.substring(0, entName.length()- 6).replace('/', '.'));
+					if (PluginLoader.isPluggableClass(cls)) classes.add((Class<Pluggable>) cls);
+				} catch (ClassNotFoundException e) {
+					System.err.println("Can't load Class" + entName);
+					e.printStackTrace();
+				}
+			}
+		}
+		
+		jaris.close();
+		
+		return classes;
+	}
+
+	private static boolean isPluggableClass(Class<?> cls) {
+		for (Class<?> i: cls.getInterfaces()) {
+			if (i.equals(Pluggable.class)) return true;
+		}
+		
+		return false;
+
+	}
+
+	private static URL[] fileArrayToURLArray(File[] files) throws MalformedURLException {
+		URL[] urls = new URL[files.length];
+		
+		if(urls == null) return null;
+		
+		for(int i = 0; i < files.length; i++) {
+			urls[i] = files[i].toURI().toURL();
+		}
+		
+		return urls;
 	}
 
