Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 4196

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Crystal Space 1.2.1: 4.18.2 Java Bindings</title>

<meta name="description" content="Crystal Space 1.2.1: 4.18.2 Java Bindings">
<meta name="keywords" content="Crystal Space 1.2.1: 4.18.2 Java Bindings">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Java-Bindings"></a>
<a name="0"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="iScript-Interface.html#0" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="Perl-Bindings.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Using-Crystal-Space.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="Scripting-Languages.html#0" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<hr size="1">
<h3 class="subsection"> 4.18.2 Java Bindings </h3>


<p><em>Written by Eric Sunshine, <a href="mailto:sunshine@sunshineco.com">sunshine@sunshineco.com</a></em>.
</p>
<p>The csJava module provides access to Crystal Space from Java in the form of a
set of classes in the package <samp>&lsquo;org.crystalspace3d&rsquo;</samp> which can be imported
into pure Java programs. The csJava module consists of a <small>JAR</small> package,
<tt>&lsquo;crystalspace.jar&rsquo;</tt>, and a shared library, <tt>&lsquo;csjava&rsquo;</tt>.
</p>
<p>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
<small>API</small> 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 <a href="Tutorial-Simple.html#0">Simple Tutorial 1: Basic Setup, World Creation</a>).
</p>
<p>Presently, the caJava module can be built only by people using Jam or &ldquo;make&rdquo;
to build Crystal Space. To build csJava, follow these instructions:
</p>
<ol>
<li>
Install Swig.


<p><a href="http://www.swig.org/">http://www.swig.org/</a>
</p>
</li><li>
Install a Java <small>SDK</small>. Crystal Space has been tested with Sun's Java2
<small>SDK</small>, Standard Edition 1.4.x. After installing Java, be sure that the
<samp>&lsquo;java&rsquo;</samp> and <samp>&lsquo;javac&rsquo;</samp> commands are found by your <samp>&lsquo;PATH&rsquo;</samp> environment
variable, or set <samp>&lsquo;JAVA_HOME&rsquo;</samp>.


<p><a href="http://java.sun.com/j2ee/1.4/download.html">http://java.sun.com/j2ee/1.4/download.html</a>
</p>
</li><li>
Install Ant, a &ldquo;make&rdquo;-like tool for Java. After installing Ant, be sure that
the <samp>&lsquo;ant&rsquo;</samp> command is found by your <samp>&lsquo;PATH&rsquo;</samp> environment variable, or
set <samp>&lsquo;ANT_HOME&rsquo;</samp>.


<p><a href="http://ant.apache.org/">http://ant.apache.org/</a>
</p>
</li><li>
Configure Crystal Space. The configure script should recognize the <samp>&lsquo;java&rsquo;</samp>,
<samp>&lsquo;javac&rsquo;</samp>, <samp>&lsquo;ant&rsquo;</samp>, and <samp>&lsquo;swig&rsquo;</samp> commands, and perform a &ldquo;Java SDK
usability&rdquo; check. If all checks succeed, continue to the next step.

</li><li>
Build and optionally install Crystal Space. The csJava module will be built
along with the rest of the project.
</li></ol>

<p>Once Crystal Space is built and optionally installed, you can use the csJava
module in your own programs. To do so, follow these instructions:
</p>
<ol>
<li>
Tell Java where to find <tt>&lsquo;crystalspace.jar&rsquo;</tt> by setting your
<samp>&lsquo;CLASSPATH&rsquo;</samp> environment variable to point at the <small>JAR</small> file. If you
installed Crystal Space, then the <small>JAR</small> file will reside at:


<p><code>${prefix}/share/crystalspace/bindings/java/crystalspace.jar</code>
</p>

<p>where ${prefix} is the installation path (typically, <tt>&lsquo;/usr/local&rsquo;</tt>). If
you did not install Crystal space, then the <small>JAR</small> file will be in the
top-level build directory (this will be the <tt>&lsquo;CS&rsquo;</tt> directory if you
configured and built in the <tt>&lsquo;CS&rsquo;</tt> directory). For convenience in testing,
you can also point your <samp>&lsquo;CLASSPATH&rsquo;</samp> variable at the current directory
(<samp>&lsquo;.&rsquo;</samp>).
</p>
</li><li>
Tell Java where to find the csJava shared library by setting your
<samp>&lsquo;LD_LIBRARY_PATH&rsquo;</samp> environment variable on Unix, your <samp>&lsquo;PATH&rsquo;</samp> variable
on Windows, or your <samp>&lsquo;DYLD_LIBRARY_PATH&rsquo;</samp> variable on MacOS/X. On Unix, the
library's name is <tt>&lsquo;libcsjava.so&rsquo;</tt>; on Windows it is <tt>&lsquo;csjava.dll&rsquo;</tt>; and
on MacOS/X, it is <tt>&lsquo;libcsjava.jnilib&rsquo;</tt>. If you installed Crystal Space, then
the library will reside at:


<p><code>${prefix}/share/crystalspace/bindings/java</code>
</p>

<p>If you did not install Crystal Space, then it will be in the top-level build
directory.
</p>
</li><li>
If necessary, set your <samp>&lsquo;CRYSTAL&rsquo;</samp> environment variable to allow Crystal
Space to locate its plugin modules and other resources.

</li><li>
In the directory containing your Java program, <tt>&lsquo;myprog.java&rsquo;</tt>, compile it
with the <samp>&lsquo;javac&rsquo;</samp> command: <samp>&lsquo;javac myprog.java&rsquo;</samp>

</li><li>
Run your program: <samp>&lsquo;java myprog&rsquo;</samp>
</li></ol>

<p>The sample program <tt>&lsquo;SimpleRoom.java&rsquo;</tt> provides a nice example of how to
utilize Crystal Space from Java. It provides the same functionality as the
first C++ tutorial (see section <a href="Tutorial-Simple.html#0">Simple Tutorial 1: Basic Setup, World Creation</a>).  If you installed Crystal Space,
then <tt>&lsquo;SimpleRoom.java&rsquo;</tt> will reside at:
</p>

<p><code>${prefix}/share/crystalspace/bindings/java/SimpleRoom.java</code>
</p>

<p>If you did not install Crystal Space, then you can find it in the Crystal Space
source tree at <tt>&lsquo;CS/scripts/java/SimpleRoom.java&rsquo;</tt>. To experiment with
<tt>&lsquo;SimpleRoom.java&rsquo;</tt>, copy it to a convenient work directory, compile it with
<samp>&lsquo;javac&rsquo;</samp>, and run it with <samp>&lsquo;java&rsquo;</samp>.  Here is a sample session on
<small>GNU</small>/Linux illustrating the above instructions:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">% cd CS
% ./configure
...
checking for swig... swig
checking if swig version &gt;= 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
</pre></td></tr></table>
<p>On Windows and MacOS/X, the procedure is almost identical. The primary difference is that, rather than setting <samp>&lsquo;LD_LIBRARY_PATH&rsquo;</samp>, you need to set the <samp>&lsquo;PATH&rsquo;</samp> environment variable on Windows to point at the directory containing <tt>&lsquo;csjava.dll&rsquo;</tt>; or the <samp>&lsquo;DYLD_LIBRARY_PATH&rsquo;</samp> variable on MacOS/X to point at the directory containing <tt>&lsquo;libcsjava.jnilib&rsquo;</tt>.
</p>
<hr size="1">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="iScript-Interface.html#0" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="Perl-Bindings.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Using-Crystal-Space.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="Scripting-Languages.html#0" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

</p>
</body>
</html>