The Eclipse JavaCC plugin and Mac OS X

01 Apr 2009

Lately I've been trying to get the Eclipse JavaCC plugin to work on my Mac 10.5.6 laptop with Eclipse 3.4.2. I was having all sorts of problems... basically the ones which folks are discussing here. After fiddling around a bit I ended up checking out the plugin and rebuilding the plugin.jar file using Java 1.5 and that did the trick. So, to get the Eclipse JavaCC plugin v1.5.13 working, try this:

  • Install the JavaCC plugin using the instructions outlined here.
  • Download this new plugin.jar file.
  • Shut down Eclipse and copy the plugin.jar file into the plugin directory. On my Mac I've got Eclipse installed in /Users/tom/eclipse, so I copied the jar file to /Users/tom/eclipse/plugins/sf.eclipse.javacc_1.5.13/plugin.jar
  • Restart Eclipse and create a new grammar file (File => New => Java Project, File => New => File, name it foo.jj)
  • Paste in some boilerplace JavaCC grammar contents, e.g.:
  • options {
    public class Foo {}
    TOKEN : {
      <HI : "hello">
    void Foo() : {} {
  • The file icon should now look like a little "JJ" and the outline view should contain the token definitions and whatnot.

Hopefully that helps someone. And if you're working with JavaCC, check out my JavaCC book!