README

This is the java-gnome language bindings project. We endeavour to
provide a high quality library you can use to write GTK and GNOME programs.
The underlying APIs are elegantly transformed into Java and carefully
documented so that anyone new to Linux or Open Source can rapidly be on their
way to creating fabulous applications.

<!--
If you didn't know, the project website is:  

	http://java-gnome.sourceforge.net

where we host the API documentation, web versions of all the design files, and
tutorials to help get people started. Contact information, release notes and
and project news will also be found there.
-->

This README file is devoted to helping you get started building the
bindings themselves. 

Building java-gnome
===================

For the impatient:

    $ tar xjf java-gnome-4.0.7.tzr.bz2
    $ cd java-gnome-4.0.7
    $ ./configure
    $ make

But there's a bunch of stuff you probably want to know, so read on!


1. Get the source code
----------------------

### From a release tarball ###

You can download a java-gnome release from the GNOME FTP server at:  
[`http://ftp.gnome.org/pub/gnome/sources/java-gnome/4.0/`][mirror]

Once you've downloaded the latest source tarball:

    $ tar xjf java-gnome-4.0.7.tzr.bz2
    $ cd java-gnome-4.0.7

And go on to step 2 for details about options you can pass to the
configuration command.


### Or checkout the source ###

If you want a newer version of the code than the tarball you might have, you
can always check it out over the net. We use Bazaar (`bzr`), an advanced
third-generation Distributed Version [or Revision] Control System, to manage
our source code. 

Getting a checkout is easy:

    $ bzr checkout http://research.operationaldynamics.com/bzr/java-gnome/mainline java-gnome
    $ cd java-gnome


2. Run `./configure`
--------------------

The top level directory contains a custom `./configure` which detects your
Operating System variant, sets defaults accordingly, verifies the location of
prerequisites (the various `.jar` files), and finally chooses a Java bytecode
compiler and Java Virtual Machine runtime environment. The configuration
output is a Makefile fragment which is written to `.config` and subsequently
included by the top level `Makefile`.

So run it already:

    $ ./configure

### Background ###

The steps necessary to configure and build a Java project are quite different
than those needed to construct a program written in a more traditional
language. Unlike C, for example, there is no need to do substitution across
the codebase nor to worry about conditional compilation; `#ifdef` is not
something we do in Java. This is in no small part because the Java class
libraries and the language itself have been remarkably stable. To build and
run a Java program, however, three things are necessary:

 * locate pre-requisite libraries (`.jar`s), and form a `CLASSPATH`;

 * locate, validate, and select a Java compiler; and

 * locate, validate, and select a Java runtime.

That's it! From there, often a single compiler invocation will take care of
building an entire program, but these preconditions must be satisfied before
compiling is possible. _(Incidentally, tools like Ant are no help with any of
this -- it just takes care of the build part; and don't even think about
suggesting the GNU autotools -- they are a complex, arcane, and bloated
nightmare that don't address with the Java specific challenges at all)_.

At the moment, we use Andrew Cowie's "Equivalence" build system, which is
composed of a straight-forward (if somewhat overweight) Perl program along
with a simple Makefile which together carry out the task of configuring and
building the library. Right now, Gentoo Linux, Debian Linux, Fedora Core
Linux, and Solaris Unix should be detected properly and result in working
configurations. If you are running a different operating system or
distribution, please contact us and we'll add it -- it's just a matter of
identifying the location of a few things. Better yet, look in the `configure`
Perl script -- the places where OS is switched are obvious, and just add what
you need to add, and send us a patch.

Hopefully in the not to distant future we will be able to switch to Robert
Collins's new "Buildtool". His approach to configuration and building will
revolutionize the Free and Open Source Software universe, and we look forward
to participating in the development of his work.

Meanwhile...


### Customizing build options ###

You can override the choices `configure` makes by listing parameters on the
command line, like this:

    $ ./configure compiler=jikes runtime=jamvm

This facilitates easily switching between runtimes and compilers for testing.
At the moment, the available selections are:

* `compiler` --> javac, jikes, gcj

* `runtime`  --> java, cacao, jamvm, cacao, gij, kaffe

oh, and there's:

* `quiet` -- (don't output anything)

The whole point of the Equivalence's `configure` script is to figure things
out for you, but if it can't quite figure out where Java is, you can override
it by specifying an alternate location to find a JDK and/or GCJ, using either
of the following:

* `jdk` -- where to find a traditional Java Development Kit, ie `JAVA_HOME`

* `gcj` -- prefix of an alternate GCJ install

* `jamvm` -- path to the JamVM executable

* `cacao` -- path to the CACAO executable

Examples:

    $ ./configure
    $ ./configure jdk=/opt/sun-jdk-bin-1.4.2.04
    $ ./configure jamvm=/home/joe/custom/bin/jamvm runtime=jamvm

Your configuration is persistent across builds in that checkout, ie, `make
clean` won't force you to reconfigure (though `make distclean` will). The
`configure` script runs very quickly, so it's no big deal if you have to
re-run it.


3. Build
--------

Once you've configured, compiling java-gnome is as simple as running Make:

    $ make

If you're having trouble with something as Make runs and need to debug it, you
can try:

    $ V=1 make

This will show you the actual commands being executed (ie, Make's normal
behaviour, which we override for appearances sake). If you're still stumped,
you might try having a look at `.config` which is where all the Make variables
come from.


4. Install
----------

There is no `make install` step at this point. As java-gnome progresses from
being a prototype we will add that in an appropriate fashion. For now, the
build products end up in `tmp/`:

    tmp/gtk-4.0.jar
    tmp/libgtkjni-4.0.jar

and if you are building for GCJ, you'll also end up with:

    tmp/libgtkjava-4.0.jar


Using the bindings
==================

There is a tiny and trivial trivial demonstration program in the `tests/`
directory of the bindings. If you would like to see it, compile it with
something like:

    $  javac -classpath tmp/gtk-4.0.jar -d tmp/classes tests/prototype/Experiment.java

and then run it with the following:

    $  java -classpath tmp/gtk-4.0.jar:tmp/classes -Djava.library.path=tmp Experiment

This shows you how you can reference and use the library as they are presently
built in `tmp/`. Note the necessity to tell the VM where to find
`libgtkjni-4.0.so`. If you get an `UnsatisfiedLinkError` you've stuffed this
part up.


Status
======

java-gnome 4.0 is a prototype that demonstrates the design and architecture we
will be following as we implement the new Java bindings for GTK and GNOME. I
am quite pleased with the reception that it has received as it has been
presented around the world, and we are hopeful that we will raise the funds
necessary to see this work developed into a full-coverage library.


Get Involved
------------

If you would like to get involved yourself as an individual, we would welcome
your contribution. See [`HACKING`](HACKING.html). If you are working on an
application, want to learn more, or are just curious, join us online in
`#java-gnome` on `irc.gimp.net`.

Happy coding!

AfC

`--`  
Andrew Frederick Cowie  
Managing Director,  
[Operational Dynamics](http://www.operationaldynamics.com/),  
a Change Management consultancy...

Maintainer,  
[java-gnome](http://java-gnome.sourceforge.net/),  
opening GTK and GNOME to Java programmers!

_Last modified 1 Jan 07_

[mirror]: http://ftp.gnome.org/pub/gnome/sources/java-gnome/4.0/

<!--

  Copyright (c) 2006-2007 Operational Dynamics Consulting Pty Ltd 

  As project documentation, this file forms an integral part of the source
  code of the library it accompanies, and thus is made available to you by the
  authors under the terms of the "GNU General Public Licence, version 2". See
  the LICENCE file for the terms governing usage, copying and redistribution.

  vim: set textwidth=78 nowrap:

-->
