Glk for Java: Installation

The steps you need to take are:

  1. Set up the include directories for your Java SDK
  2. Build everything
  3. Install the shared libraries
  4. Add jniglk.jar to your classpath
  5. Test jniglk

1. Set up the include directories for your Java SDK

The first four variables in the Makefile describe where your copy of the Java SDK is loaded. If it's somewhere other than /usr/local/jdk or you're compiling on something other than Linux, you'll need to change the paths in this section.

2. Build everything

On Linux, this should be as simple as typing make. On other systems, you may have to adjust some of the variables at the top of the Makefile first.

3. Install the shared libraries

Again, on Linux this should just be a matter of becoming root and typing make install. On other systems you may need to alter the "INSTALL=" and "LDCONFIG=" lines manually in the Makefile.

If you want to install manually, you have to copy libxglk.so and libjniglk.so to somewhere where your dynamic linker will find them, and jniglk to somewhere on your path. If your system requires you to run ldconfig after updating shared libraries then do that too.

4. Add jniglk.jar to your classpath

You may want to copy jniglk.jar to somewhere other than where you built it. If you used make install, it was copied to the same place as the .so files - by default, /usr/local/lib.

If you're using a Bourne shell then add the following line to the end of your .profile / .bash_profile file:

	CLASSPATH=$CLASSPATH:/usr/local/lib/jniglk.jar export CLASSPATH

If you're using a C shell then add this line to the end of your .cshrc / .tcshrc file

	setenv CLASSPATH ${CLASSPATH}:/usr/local/lib/jniglk.jar

5. Test jniglk

To test the installation, start a new shell and type jniglk. If the program runs successfully, you should get a window starting "JniGlk default screen".

Assuming that was OK, change to the directory in which the programs were built and type jniglk Model. If all goes according to plan, you should see the standard Glk model program. Three new commands have been added to it:

ITERATE
will list all windows, streams and filerefs in the system.
DISPATCH
will list all the constants and functions supported by the version of xglk being used. It also parses the function prototypes.
TESTDISP
does a few tests on the dispatch layer, including checks that dispatch-style functions can be mixed with normal functions.

The Multiwin sample has also been converted to Java; to test that, type jniglk MultiWin.