diff --git a/.bzrignore b/.bzrignore
index 9aefbbac4a1b145311f9bd884612d08335e98465..791ee8eebf0b0632e37423f86ca64d04a4d795ab 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -17,3 +17,4 @@ lib/java/se/lth/control/labcomm/LabCommReader.class
 lib/java/se/lth/control/labcomm/LabCommSample.class
 lib/java/se/lth/control/labcomm/LabCommType.class
 lib/java/se/lth/control/labcomm/LabCommWriter.class
+gen
diff --git a/examples/simple/Decoder.java b/examples/simple/Decoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..278c5aa8b293678ac34e6f8d99d1a5ee0322f6d0
--- /dev/null
+++ b/examples/simple/Decoder.java
@@ -0,0 +1,43 @@
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import se.lth.control.labcomm.LabCommDecoderChannel;
+
+public class Decoder
+  implements TwoInts.Handler, IntString.Handler 
+{
+
+  LabCommDecoderChannel decoder;
+
+  public Decoder(InputStream in) 
+    throws Exception 
+  {
+    decoder = new LabCommDecoderChannel(in);
+    TwoInts.register(decoder, this);
+    IntString.register(decoder, this);
+
+    try {
+      System.out.println("Running decoder.");
+      decoder.run();
+    } catch (java.io.EOFException e) {
+	System.out.println("Decoder reached end of file.");
+    }
+  }
+
+  public void handle_TwoInts(TwoInts d) throws java.io.IOException {
+    System.out.println("Got TwoInts, a="+d.a+", b="+d.b);
+  }
+
+  public void handle_IntString(IntString d) throws java.io.IOException {
+    System.out.println("Got IntString, x="+d.x+", s="+d.s);
+  }
+
+
+  public static void main(String[] arg) throws Exception {
+    Decoder example = new Decoder(
+      new FileInputStream(new File(arg[0]))
+    );
+  }
+}
+
diff --git a/examples/simple/Encoder.java b/examples/simple/Encoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..40eb8284aa6586cf227c75f3bc7547e34f4aa8a3
--- /dev/null
+++ b/examples/simple/Encoder.java
@@ -0,0 +1,42 @@
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+import se.lth.control.labcomm.LabCommEncoderChannel;
+
+public class Encoder 
+{
+
+  LabCommEncoderChannel encoder;
+
+  public Encoder(OutputStream out) 
+    throws Exception 
+  {
+    encoder = new LabCommEncoderChannel(out);
+    TwoInts.register(encoder);
+    IntString.register(encoder);
+  }
+
+  public void doEncode() throws java.io.IOException {
+    TwoInts x = new TwoInts();
+    x.a = 17;
+    x.b = 42;
+
+    IntString y = new IntString();
+    y.x = 37;
+    y.s = "Testing, testing";
+
+    TwoInts.encode(encoder, x);
+    IntString.encode(encoder, y);
+  }
+
+
+  public static void main(String[] arg) throws Exception {
+    FileOutputStream fos = new FileOutputStream(new File(arg[0]));
+    Encoder example = new Encoder(fos);
+    example.doEncode();
+    fos.close();
+  }
+
+}
+
diff --git a/examples/simple/compile.sh b/examples/simple/compile.sh
index d6a9f67c8e4c2c08aefbbd16ac45d4196df174c8..7d455a2b9ecc250542b57e7daff8ad0e8395ec14 100644
--- a/examples/simple/compile.sh
+++ b/examples/simple/compile.sh
@@ -1 +1,3 @@
-java -jar ../../labComm.jar --java=java simple.lc
+java -jar ../../labComm.jar --java=gen simple.lc
+
+javac -cp ../../lib/java:. gen/*.java Encoder.java Decoder.java
diff --git a/examples/simple/run.sh b/examples/simple/run.sh
new file mode 100644
index 0000000000000000000000000000000000000000..95a1d728389317010c1ef317d862939ce3c6b75b
--- /dev/null
+++ b/examples/simple/run.sh
@@ -0,0 +1,2 @@
+java -cp .:../../lib/java:gen Encoder encoded_data
+java -cp .:../../lib/java:gen Decoder encoded_data