Index: trunk/JFCMonitor/.classpath
===================================================================
--- trunk/JFCMonitor/.classpath	(revision 263)
+++ trunk/JFCMonitor/.classpath	(revision 263)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: trunk/JFCMonitor/.project
===================================================================
--- trunk/JFCMonitor/.project	(revision 263)
+++ trunk/JFCMonitor/.project	(revision 263)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>JFCCapture</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/JFCListener.java
===================================================================
--- trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/JFCListener.java	(revision 263)
+++ trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/JFCListener.java	(revision 263)
@@ -0,0 +1,27 @@
+package de.ugoe.cs.eventbench.jfcmonitor;
+
+import java.awt.AWTEvent;
+import java.awt.event.AWTEventListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+
+public class JFCListener implements AWTEventListener {
+
+	@Override
+	public void eventDispatched(AWTEvent event) {
+		// TODO implement event handler in a way that monitors the click instead of just writing strings to the console
+		if( event instanceof MouseEvent ) {
+			MouseEvent mouseEvent = (MouseEvent) event;
+			if( mouseEvent.getID()==MouseEvent.MOUSE_CLICKED ) {
+				System.out.println(event.toString());
+			}
+		}
+		if( event instanceof KeyEvent ) {
+			KeyEvent keyEvent = (KeyEvent) event;
+			if( keyEvent.getID()==KeyEvent.KEY_TYPED ) {
+				System.out.println(event.toString());
+			}
+		}
+	}
+
+}
Index: trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/JarLauncher.java
===================================================================
--- trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/JarLauncher.java	(revision 263)
+++ trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/JarLauncher.java	(revision 263)
@@ -0,0 +1,66 @@
+package de.ugoe.cs.eventbench.jfcmonitor;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+// TODO decent exception handling; currently no exception are caught!
+public class JarLauncher {
+	
+	String workingDir = System.getProperty("user.dir") + "/";
+	String jarfile;
+	String[] args;
+	
+	String[] classPath = new String[]{};
+	String mainClassName = "";
+	ClassLoader costumClassLoader;
+	
+	public JarLauncher(String jarfile, String[] args) {
+		this.jarfile = jarfile;
+		this.args = args;
+	}
+
+	public void exec() throws FileNotFoundException, IOException, ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InterruptedException {
+		getInfoFromJar();
+		initClassLoader();
+		startSUT();
+	}
+	
+	private void getInfoFromJar() throws FileNotFoundException, IOException {
+		JarInputStream jarInputStream = new JarInputStream(new FileInputStream(workingDir+jarfile));
+		Manifest manifest = jarInputStream.getManifest();
+		mainClassName = manifest.getMainAttributes().getValue("Main-Class");
+		String jarClassPath = manifest.getMainAttributes().getValue("Class-Path");
+		String[] jarClassPathElements = jarClassPath.split(" ");
+		classPath = new String[jarClassPathElements.length];
+		for (int i=0; i<jarClassPathElements.length ; i++) {
+			classPath[i] = "file:"+workingDir+jarClassPathElements[i];
+		}
+	}
+	
+	private void initClassLoader() throws MalformedURLException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+		URLClassLoader classLoader = (URLClassLoader) ClassLoader
+				.getSystemClassLoader();
+		Method method= URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class });
+		method.setAccessible(true);
+		
+		method.invoke(classLoader, new Object[]{new URL("file:"+workingDir+jarfile)});
+		
+		for (String element : classPath) {
+			method.invoke(classLoader, new Object[]{new URL(element)});
+		}
+	}
+	
+	private void startSUT() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InterruptedException {
+		Class<?> mainClass = Class.forName(mainClassName);
+		Method mainMethod = mainClass.getMethod("main", new Class[]{String[].class});
+		mainMethod.invoke(null, new Object[]{args});
+	}
+}
Index: trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/Runner.java
===================================================================
--- trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/Runner.java	(revision 263)
+++ trunk/JFCMonitor/src/de/ugoe/cs/eventbench/jfcmonitor/Runner.java	(revision 263)
@@ -0,0 +1,20 @@
+package de.ugoe.cs.eventbench.jfcmonitor;
+import java.awt.AWTEvent;
+import java.awt.Toolkit;
+import java.awt.event.AWTEventListener;
+import java.util.Arrays;
+
+
+public class Runner {
+
+	public static void main(String[] args) throws Exception {
+		AWTEventListener listener = new JFCListener();
+		
+		Toolkit.getDefaultToolkit().addAWTEventListener(listener,
+				AWTEvent.KEY_EVENT_MASK);
+		Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK);
+		
+		JarLauncher launcher = new JarLauncher(args[0], Arrays.copyOfRange(args, 1, args.length));
+		launcher.exec();
+	}
+}
