Setting up JOGL, class examples, and your working environment For
CS 652
- Get
the Libraries
- Install
the Libraries
- Configure
your working environment
- Patch/Download
the example code
- Getting
the Libraries
- The
JOGL project website (located at https://jogl.dev.java.net/
) hosts both the JOGL library itself, as well as the native libraries for
several platforms that the JOGL library requires.
The jogl library is a .jar file (much the same format as a unix .tar
file, with extended rules to allow java to run a jar file without extracting
its contents), and the latest version (at the time of this writing) can
be downloaded here:
- JOGL
requires several native libraries to function.
These libraries can be downloaded here:
- Other
useful downloads:
- The
JOGL javadoc documentation can be viewed online here:
- or
downloaded as a zip archive here:
- JOGL
provides a collection of demo applications to test whether your JOGL instillation
and working environment are correct:
- Installing
the libraries:
- Mac
OS X: Place both the "jogl.jar" file and the following .jnilib files in
your java system libarary directory (/System/Library/Java/Extensions/):
- libjogl.jnilib
- libjogl_awt.jnilib
- libjogl_cg.jnilib
- Windows:
Following the instructions located here: (http://today.java.net/pub/a/today/2003/09/11/jogl2d.html)
install your "jogl.jar" file inside the lib/ext directory located in the
home directory of the java install (Search for the java binary if you can't
find the java home directory), and install the following native libraries
under the jre/bin directory:
- jogl.dll
- jogl_awt.dll
- jogl_cg.dll
- Linux:
The "jogl.jar" file can be placed in any directory, although it is recommended
to keep all your ".jar" files in one directory.
The library ".so" files should be placed together in one directory.
The directory "/usr/local/lib/jogl/" is suggested, although you could
create it anywhere your normal user account will have read access.
The following files should be placed in this directory:
- libjogl.so
- libjogl_awt.so
- libjogl_cg.so
- libjogl_drihack.so
- Configure
your working environment
- In
order to compile and run java code written to use the JOGL library you must
configure two environment variables.
- On
Windows and Mac OS X systems, installing the native libraries and the "jogl.jar"
file in the appropriate directories should cause the system to automatically
configure these settings properly (IE you can skip to step 4 if you are
able to compile and run JOGL applications after completing step 2).
However, if you are unable to compile and run any of the JOGL demos
provided at the JOGL home page, try to configure your environment variables
as described below.
- Windows
users should read the following on how to use and set environment variables:
http://support.microsoft.com/default.aspx?scid=kb;en-us;310519
- On
Unix based operating systems like Linux and Mac OS X you can set environment
variables on the command line in the following way:
- using
the bash shell (standard on osf1): export VARIABLE=value example:
- export
TERM=xterm
- export
CLASSPATH=/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar
- export
CLASSPATH=$CLASSPATH:~/jars/jogl.jar
- The
third example uses the previous value in the CLASSPATH variable as part
of the new value. When
a dollar sign is placed before a variable name it is "dereferenced" and
the value stored in that variable is used instead of the variable itself.
If CLASSPATH had been empty before the second example, and examples
2 and 3 occurred one right after the other, the value stored in the CLASSPATH
variable would be /System/Library/Frameworks/JavaVM.framework/Classes/classes.jar
- Setting
a variable in this way only sets that variable for the current shell session,
meaning that if you open a new shell (new window if you're using xterm
or apples Terminal.app), the variable will be the same as it was before
you issued the export command.
To set this variable every time you should place the export command
inside your shell's rc file or in your .profile file (the bash rc file
is located in your home directory under the name .bashrc).
- The
CLASSPATH environment variable should be set to include the jogl.jar file.
Make sure you include the full path to the jogl.jar file, including
just the directory above the jogl.jar file is not enough:
- CLASSPATH=$CLASSPATH:~/jars/jogl.jar
<- OK
- CLASSPATH=$CLASSPATH:~/jars/
<- Won't work!
- On
Linux, creating the /usr/local/lib/jogl directory and adding the native
libraries to it is not sufficient to let java know where those libraries
are. When running
a JOGL application you must specify a list of directories where java looks
for library binaries, similar to the CLASSPATH environment variable except
that this is a setting specific to java and is set through a java property
on the command line. If
you placed your .so files in the directory "/usr/local/lib/jogl" you should
use the following argument with java:
- java
-Djava.library.path=/usr/local/lib/jogl/ MyJoglProgram
- Patch/Download
the example code.
- Currently
the provided code (available here: http://www.cs.gmu.edu/%7Ejchen/graphics/jogl/notes/src.zip
) is compatible with 2003-2005 release builds.
In order to make the code compatible with the newer releases of JOGL
several non-backwards compatible backwards changes had to be made to the
code. These changes are
included in a patch available here:
- To
apply the patch on a unix based computer, use the command line utility called
"patch". If you are using
a windows machine, copy the example files on to your osf1 account, follow
the instructions below and copy the modified files back.
- Unzip
cs652patches.zip // by Jim X. Chen
- Unzip the contents of the "src.zip" file, and rename the directory "cs652-examples".
This is important, as the patch utility will look for a directory
with this name to apply the patches to.
- unzip
src.zip
- mv
src/ cs652-examples/
- mv cs652-examples cs652patches // by Jim X. Chen
- Next,
apply the patch in the following way
- cd
cs652patches //by Jim X. Chen
- patch -p0 < cs652-examples.patch2 // by Jim X. Chen
- patch -p0 < cs652-examples.patch1
- If
the above command fails for some reason, you can still apply the patches
individually. The individual
patch files are all found within the "patches" directory inside the cs652patches
directory. The are named
according to the name of the file that they are applied to: <filename>.patch<N>.
<filename> is the name of the old file, and N is some integer
representing the version of the patch.
If newer patches are released, they will have higher version numbers.
An example of applying an individual
patch to the file "J1_0_Point.java":
- patch
J1_0_Point.java J1_0_Point.java.patch0
- In
the future, a zip of the modified files may be provided in which case you
will not need to download or apply the patches.