How to build the Jogl OpenGL binding for Java


Here are the steps that are required in order to build the Jogl OpenGL binding from a fresh copy of the source distribution:
  1. Install Ant:
    Download and unpack Ant 1.6.1 or later from http://ant.apache.org and add the bin/ subdirectory to your PATH environment variable. (Later versions of Ant should work; 1.6.2 has been tested successfully.)
  2. Install ANTLR:
    Download and unpack ANTLR 2.7.2 from http://www.antlr.org. (Later versions of ANTLR should work; ANTLR 2.7.3 has been tested successfully.)
  3. Unset your CLASSPATH environment variable:
    The Ant build requires that the Jogl jars not be visible on the classpath. On Unix, type unsetenv CLASSPATH into a csh or tcsh shell, or unset CLASSPATH into a Bourne shell. On Windows, type set CLASSPATH= into a command prompt.
  4. Copy and edit jogl.properties:
    Edit the copy to change any settings that are necessary, in particular the location of the ANTLR jar file (typically $HOME/antlr-2.7.2/antlr.jar).
  5. Build the source tree:
    Open a command shell in the "make" directory of the source tree and type "ant [target]", where [target] is one of linux, macosx, solaris, win32.vc6, win32.vc7, or win32.mingw.
  6. Add Jogl to your CLASSPATH:
    To be able to use Jogl once built, you must add the build process' resulting jogl.jar (/build/jogl.jar) to your CLASSPATH environment variable.
  7. Add Jogl to your PATH or LD_LIBRARY_PATH:
    To be able to use Jogl once built, you must also add the build process's JNI code library directory (/build/obj) to your PATH (on Windows) or LD_LIBRARY_PATH (on Unix platforms) environment variable.
  8. Test if everything's working:
    To test if everything went well, you should check out the source code for the jogl-demos project (available at http://jogl-demos.dev.java.net/), build the demos using the supplied instructions, and run the Gears demo ("java demos.gears.Gears").
  9. Build Javadoc:
    "ant javadoc" will produce the end-user documentation for Jogl along with some auxiliary utility packages. The developers' documentation, including that for the GlueGen tool, can be generated for your current platform using one of the following commands: "ant javadoc.dev.win32", "ant javadoc.dev.x11", or "ant javadoc.dev.macosx". (The javadoc for the Cg binding can be built by inserting -Djogl.cg=1 into the command line as above.)
Note that there are a lot of warnings produced by ANTLR about the C grammar and our modifications to some of the signatures of the productions; the C grammar warnings have been documented by the author of the grammar as having been investigated completely and harmless, and the warnings about our modifications are also harmless.

Common build problems

  1. Your CLASSPATH environment variable appears to be set (some JOGL classes are currently visible to the build.), and $CLASSPATH isn't set.
    An older version of JOGL was installed into the extension directory of the JDK you're using to build the current JOGL. On Windows and Linux, delete any ANTLR jars from jre/lib/ext, and on Mac OS X, delete them from /Library/Java/Extensions. It is generally not a good idea to drop JOGL directly into the extensions directory, as this can interfere with upgrades via Java Web Start.
  2. CharScanner; panic: ClassNotFoundException: com.sun.gluegen.cgram.CToken
    This occurs because ANTLR was dropped into the Extensions directory of the JRE/JDK. On Windows and Linux, delete any ANTLR jars from jre/lib/ext, and on Mac OS X, delete them from /Library/Java/Extensions. Use the antlr.jar property in the build.xml to point to a JRE-external location of this jar file.
- Christopher Kline and Kenneth Russell, June 2003