title: JAR Bundler using OSXAdapter causing application to lag or terminate
body: <p>I've created a simple Java application that each second for for 10 seconds consecutive seconds adds a new row to a <code>JTable</code>. It consists of three classes.</p>
  <p><strong>The main class that gets called once the program is started</strong></p>
  <pre><code>public class JarBundlerProblem {
      public static void main(String[] args)
      {
          System.err.println(&quot;Initializing controller&quot;);
          new Controller();
      }
  }
  </code></pre>
  <p><strong>A controller that creates the GUI and alters it through <code>doWork()</code></strong></p>
  <pre><code>public class Controller {
      public Controller()
      {
          doWork(null);
      }
      public static void doWork(String s)
      {
          GUI gui = new GUI();
          
          for (int i=0; i&lt;10; i++)
          {
              gui.addRow(&quot;Line &quot;+(i+1));
              try {
                  Thread.sleep(1000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  </code></pre>
  <p><strong>And finally, the GUI</strong></p>
  <pre><code>import javax.swing.JFrame;
  import javax.swing.JScrollPane;
  import javax.swing.JTable;
  import javax.swing.table.DefaultTableModel;
  
  public class GUI {
      private JFrame frame = new JFrame();
      private DefaultTableModel model = new DefaultTableModel();
      private JTable table = new JTable(model);
      private JScrollPane pane = new JScrollPane(table);
      
      public GUI()
      {
          model.addColumn(&quot;Name&quot;);
          
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add(pane);
          frame.pack();
          frame.setVisible(true);
      }
      public void addRow(String name)
      {
          model.addRow(new Object[]{name});
      }
  }
  </code></pre>
  <p>Since I'm developing for OS X, and I need to be able to associate my application with a certain file type (let's say <code>.jarbundlerproblem</code>), I have to bundle my <code>JAR</code> file into an <code>APP</code> using <a href="http://developer.apple.com/library/mac/#documentation/Java/Conceptual/Jar_Bundler/Introduction/Introduction.html" rel="nofollow noreferrer">Apple Jar Bundler</a>. I have done this successfully, my application opens, counts to ten, writing out each second.</p>
  <h1>Now, for the problem</h1>
  <p>By default, double-clicking a <code>.jarbundlerproblem</code>, and associating the file with my application, will not pass the file I double-clicked as an argument to the application. Apparently, this is just Java on OS X works.</p>
  <p>Since I need to be able to see what file was double-clicked, I'm using <a href="http://developer.apple.com/library/mac/#samplecode/OSXAdapter/Introduction/Intro.html" rel="nofollow noreferrer">OSXAdapter</a> which is a Java library made by Apple for the purpose. This, I've implemented by altering the constructor of my <code>Controller</code> class and added another method <code>registerForMacOSXEvents()</code>:</p>
  <pre><code>public Controller()
  {
      registerForMacOSXEvents();
      //doWork(null);
  }
  public void registerForMacOSXEvents() {
      try {
          OSXAdapter.setFileHandler(this, getClass().getDeclaredMethod(&quot;doWork&quot;, new Class[] { String.class }));
      } catch (Exception e) {
          System.err.println(&quot;Error while loading the OSXAdapter:&quot;);
          e.printStackTrace();
      }
  }
  </code></pre>
  <p>But after this (minor) modification, my application starts acting up. Sometimes, it doesn't open, even though I can see in the Console that it just started (<code>Initializing controller</code> is written), but after a few attempts, it will eventually start, but the windows will be completely blank for the first 10 seconds, and after that, the 10 rows will be added.</p>
  <h1>Help</h1>
  <p>Now, I've struggled with this quite a bit, and it seems like there isn't a lot of documentation regarding neither OSXAdapter nor Jar Bundler. What am I doing wrong? Or shouldn't I be using OSXAdapter or Jar Bundler in the first place?</p>