[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] | [ Search: ] |
Written by Eric Sunshine, sunshine@sunshineco.com.
The csJava module provides access to Crystal Space from Java in the form of a set of classes in the package ‘org.crystalspace3d’ which can be imported into pure Java programs. The csJava module consists of a JAR package, ‘crystalspace.jar’, and a shared library, ‘csjava’.
The Crystal Space classes, interfaces, and methods exported to Java are used in almost the same fashion as in C++. Consequently, the Crystal Space Public API Reference can be consulted in most cases. There is also a sample program which shows concretely how to utilize Crystal Space from Java. It performs the same functionality as the first C++ tutorial (see section Simple Tutorial 1: Basic Setup, World Creation).
Presently, the caJava module can be built only by people using Jam or “make” to build Crystal Space. To build csJava, follow these instructions:
Once Crystal Space is built and optionally installed, you can use the csJava module in your own programs. To do so, follow these instructions:
${prefix}/share/crystalspace/bindings/java/crystalspace.jar
where ${prefix} is the installation path (typically, ‘/usr/local’). If you did not install Crystal space, then the JAR file will be in the top-level build directory (this will be the ‘CS’ directory if you configured and built in the ‘CS’ directory). For convenience in testing, you can also point your ‘CLASSPATH’ variable at the current directory (‘.’).
${prefix}/share/crystalspace/bindings/java
If you did not install Crystal Space, then it will be in the top-level build directory.
The sample program ‘SimpleRoom.java’ provides a nice example of how to utilize Crystal Space from Java. It provides the same functionality as the first C++ tutorial (see section Simple Tutorial 1: Basic Setup, World Creation). If you installed Crystal Space, then ‘SimpleRoom.java’ will reside at:
${prefix}/share/crystalspace/bindings/java/SimpleRoom.java
If you did not install Crystal Space, then you can find it in the Crystal Space source tree at ‘CS/scripts/java/SimpleRoom.java’. To experiment with ‘SimpleRoom.java’, copy it to a convenient work directory, compile it with ‘javac’, and run it with ‘java’. Here is a sample session on GNU/Linux illustrating the above instructions:
% cd CS % ./configure ... checking for swig... swig checking if swig version >= 1.3.20... yes (version 1.3.22) checking for java... /usr/java/j2sdk1.4.2_06/bin/java checking for javac... /usr/java/j2sdk1.4.2_06/bin/javac checking if Java2 SDK is usable... yes checking for ant... /usr/local/ant/bin/ant ... % jam install # (or 'make install') % csjavadir=/usr/local/share/crystalspace/bindings/java % CLASSPATH=$CLASSPATH:.:$csjavadir/crystalspace.jar % export CLASSPATH % LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$csjavadir % export LD_LIBRARY_PATH % CRYSTAL=/usr/local % export CRYSTAL % mkdir $HOME/javatest % cd $HOME/javatest % cp $csjavadir/SimpleRoom.java . % javac SimpleRoom.java % java SimpleRoom |
On Windows and MacOS/X, the procedure is almost identical. The primary difference is that, rather than setting ‘LD_LIBRARY_PATH’, you need to set the ‘PATH’ environment variable on Windows to point at the directory containing ‘csjava.dll’; or the ‘DYLD_LIBRARY_PATH’ variable on MacOS/X to point at the directory containing ‘libcsjava.jnilib’.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated using texi2html 1.76.