ANTLR VisualAge Interface


The ANTLR-VisualAge Interface tool allows you to run ANTLR from inside VisualAge for Java. ANTLR will generate classes that are directly added to a project within VisualAge for Java. If you're not familiar with ANTLR, please visit You can also read my ANTLR Tutorial at (note that the tutorial may not be up to date with ANTLR 2.7.0, but should give you the general ideas)


To install the ANTLR-VisualAge interface, you must do the following:

  1. Shutdown VisualAge for Java.

  2. Download from this site.

  3. Download the antlr 2.7.0 distribution from

  4. Download from this site

  5. Unzip into \IBMVJava\ide\tools on the drive on which you installed VisualAge for Java. This will create directory


    which contains the tool code.

    Note: If you're using VisualAge for Java, version 3.5, the install directory will be \Program Files\IBM\VisualAge for Java\ide\tools

  6. Unzip the antlr 2.7.0 distribution somewhere on your hard disk.

  7. Copy the antlr-2.7.0\antlr dir into the \IBMVJava\ide\tools\com-javadude-vaj-antlr directory. There is already an antlr directory in there, and you should end up with files like ActionElement.class inside \IBMVJava\ide\tools\com-javadude-vaj-antlr\antlr as well as several subdirectories.

    Note: If you would like, you can delete all of the ANTLR .java files from \IBMVJava\ide\tools\com-javadude-vaj-antlr\antlr. You do not need the .java files to run the tool.

  8. Unzip the on top of \IBMVJava\ide\tools\com-javadude-vaj-antlr\antlr. This should replace the Tool.class and Tool$1.class files.

  9. Start VisualAge for Java

Setting up a Project

To run ANTLR within VisualAge for Java, you must

  1. Create a project for your application. For example, you might name this project "Parser Project"

    Note that you can have multiple parser projects, each containing multiple grammars.

  2. Create grammar files with a ".g" extension that ANTLR will process

    Store these grammar files in


    Where projectName is the name of your parser project. Using the above example project, you would save grammars similar to the following.

    \IBMVJava\ide\project_resources\Parser Project\aGrammar.g
    \IBMVJava\ide\project_resources\Parser Project\someOther.g

    Use whatever editor you want to edit the grammar files. The ANTLR-VisualAge Interface does not provide a grammar editor.

Generating Parsers

  1. Open a project browser for the parser project. You can do this by double-clicking on the project from the workbench (if you haven't changed the default meaning of double-clicking).

  2. Switch to the resources tab of the project browser.

  3. Choose Tools->ANTLR->Generate Parser from the popup menu for any .g file.


    Note that if you have multiple grammar files selected, all will be processed by ANTLR.

    If you only want to process a single grammar, you may also double-click on the grammar file (or select Open from its popup menu) to run ANTLR on it.

  4. Look at the VisualAge for Java console to see any ANTLR errors.

Source Code and Sample

If you're interested in the source code behind this tool, you can download this repository file for VisualAge for Java:

Details on the VisualAge for Java Tool API can be found here.

To try the tool, you can download the Java sample grammar for ANTLR, bundled as a VisualAge for Java Feature: To use this sample (assuming you have already installed the ANTLR-VisualAge Interface):

  1. Download the above zip file
  2. Shutdown VisualAge for Java
  3. Unzip it into \IBMVJava\ide\features on the drive where you installed VisualAge for Java
  4. Start VisualAge for Java

    You should see a dialog pop up stating that it's installing the sample

  5. Choose File->Quick Start->Features->Add Feature
  6. Select "Java Parser Example" and press Ok

    Note that VisualAge will report there are errors in this project. This is normal, as the code in the Main class references the yet-to-be-generated Parser classes.

  7. Double-click on project "Java Parser Example" in the workbench.
  8. Choose the Resources tab.
  9. Select java.g and java-tree.g
  10. Choose Tools->ANTLR->Generate Parser from their popup menu.
  11. Run the Main class in Java Parser Example


The ANTLR-VisualAge interface is free for any use other than selling it as a stand-alone product.

Note that the ANTLR-VisualAge Interface is provided "as-is" without any warrantee or guarantee of suitability for any purpose. Scott Stanchfield cannot be held responsible for any damage caused by its use.

(In other words, use it for free at your own risk.)