Build OpenJDK7 under Debian Lenny — Repositore clone

I’m start series of articles devoted to download, build and install latest version of OpenJDK 7 under Debian Lenny. And in first article i want to describe how we can get latest source code from official mercurial repository.
At first stage we must read Repository Guide and install mercurial >= 0.9.4. Lenny already include mercurial 0.9.5 (1.0 version can be included in release). Also i create separate dir for openjdk repository in /opt/repos/mercurial/openjdk/openjdk7
Please be attentive, to proper clone openjdk repository you must use fclone commant (this command provided by extension called forest and not included in official mercurial package and Debian repository). Therefore you must manual install this extension:

     mkdir -p /opt/repos/mercurial/mercurial/forest/
     cd /opt/repos/mercurial/mercurial/forest/
     hg clone http://hg.akoha.org/hgforest/
     cp hgforest/forest.py /usr/share/python-support/mercurial/hgext/
   

And the configure your .hgrc to enable the extension by adding following lines:

     [extensions]
     hgext.forest=
     # or, if forest.py is not in the hgext dir:
     # forest=/usr/share/python-support/mercurial/hgext/forest.py
   

After this we are ready to clone openjdk repository:

     mkdir -p /opt/repos/mercurial/openjdk/openjdk7
     cd /opt/repos/mercurial/openjdk/openjdk7
     hg fclone http://hg.openjdk.java.net/jdk7/jdk7
   

This action require around 70 Mb and around 10-20 minutes of time. But after this you would have own copy of main openjdk development tree.
ps: You need fclone because openjdk repository use nested mercurial trees inside main tree. If you try to use clone instead of fclone you dowload only some documentation files without source code.

Introduction to Java Swarm for ABM

Swarm is a platform for agent-based models ABMs that includes:

  • A conceptual framework for designing, describing, and conducting experiments on ABMs;
  • Software implementing that framework and providing many handy tools; and
  • A community of users and developers that share ideas, software, and experience.

It mostly written in Objective-C but give ability to develop model in Java. In this article i give first introduction in Java Swarm and show how to run one of examples — Heatbugs. Heatbugs — is one of our canonical Swarm demonstrations, an example of how simple agents acting only on local information can produce complex global behavior.

All commands in this article given for Debian GNU/Linux distribution (and must work similar on most other moder Linux distributions). Good article about building and running Swarm on Debian written by Jakson Aquino (but their article don’t contain information about Java Swarm).

Java installation

Currently i don’t have information about supporting GNU Java by Swarm, therefore i use Sun Java SE 1.6.0_03 as java virtual machine. To install Sun Java on Debian you have two options:

Build Swarm with Java support

  1. Install the software necessary to download and compile swarm:

    sudo apt-get install gobjc gperf libxpm-dev libpng12-dev automake1.9 emacs21-nox libhdf5-serial-dev blt-dev cvs autoconf libtool make xfonts-75dpi xfonts-100dpi

  2. Swarm needs automake1.9. Thus, run update-alternatives and select automake1.9 if it was not the default yet (For Debian Etch — automake 1.9 is already default version):

    sudo update-alternatives —config automake

  3. Now, you can download the swarm source code. There are two options:

    • Paul Johnson’s web site:

      wget http://pj.freefaculty.org/Swarm/swarm-2.2.3.tar.gz tar -xzf swarm-2.2.3.tar.gz cd swarm-2.2.3

    • The official cvs repository:

      cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/swarm co swarm cd swarm ./autogen.sh

  4. Then, you can compile swarm with java support:

    • If you install Java from backport package:

      ./configure —with-jdkdir=/usr/lib/jvm/java-6-sun —with-gnu-ld —with-tclinclude=/usr/include/tcl8.4/ —with-tclscriptdir=/usr/lib/tcl8.4/ —with-tkscriptdir=/usr/lib/tk8.4/ —with-tcl=/usr/lib/tcl8.4/ —with-tk=/usr/lib/tk8.4 —with-tkinclude=/usr/include/tcl8.4

    • If you install Java from binary distribution archive — replace java_path on real Java installation path:

      For swarm from cvs

      ./configure —with-jdkdir=java_path —with-gnu-ld —with-tclinclude=/usr/include/tcl8.4/ —with-tclscriptdir=/usr/lib/tcl8.4/ —with-tkscriptdir=/usr/lib/tk8.4/ —with-tcl=/usr/lib/tcl8.4/ —with-tk=/usr/lib/tk8.4

      make

      sudo make install

      For swarm 2.2.3

      ./configure —with-jdkdir=java_path —with-gnu-ld —with-tclincludedir=/usr/include/tcl8.4/ —with-tclscriptdir=/usr/lib/tcl8.4/ —with-tkscriptdir=/usr/lib/tk8.4/ —with-tcldir=/usr/lib/tcl8.4/ —with-tk=/usr/lib/tk8.4

      make sudo make install

  5. Swarm is already installed. You should now put this line at the end of your ~/.bashrc, because, by default, the Makefiles that come with swarm applications are configured to look for swarm at /usr, but since we installed it at /usr/local, we need to inform the Makefiles about this:

    export SWARMHOME=/usr/local

    In addition to putting the above line in your ~/.bashrc, copy and paste it in your terminal too. When you logoff and login again the .bashrc will be re-read and the SWARMHOME environment variable automatically will be active.

Build and run Heatbugs

You can download Heatbugs from Swarm ftp:

> wget http://ftp.swarm.org/pub/swarm/apps/java/sdg/jheatbugs-2.1.tar.gz
> tar -xvzf jheatbugs-2.1.tar.gz
> cd jheatbugs-2.1/
> make

If build failed with error like:

> HeatbugModelSwarm.java:297: cannot find symbol
> symbol  : constructor FArgumentsImpl(HeatbugModelSwarm,swarm.Selector,boolean)
> location: class swarm.defobj.FArgumentsImpl
>    new FCallImpl (this, proto, sel, new FArgumentsImpl (this, sel, true)));
>                                                 ^
> 1 error

Then you must download and apply my patch for jheatbugs:

> wget http://nixdev.net/projects/swarm/patches/jheatbug-2.1-FArgumentsImpl-parameters.diff
> patch -p1 -l < jheatbug-2.1-FArgumentsImpl-parameters.diff

After this you can repeate you build. If all finished OK — you can finally run this demo:

> javaswarm StartHeatbugs

Please note that javaswarm is a script written on top of java, which set proper environment settings and run swarm java application. Now you can play with Heatbug and see it evolution.
Heatbugs in action

References

To be continued

Google Summer of Code и Google Highly Open Participation Contest

Я продолжаю свой рассказ о инициативах Google по привлечению студетов (а теперь еще и школьников) к участию в Open Source проектах. Самой интересной новостью здесь является запуск новой программы Google Highly Open Participation Contest, которая ориентирована на школьников. Сейчас она уже подходит к своему завершению и я постараюсь написать её подробный обзор.

Сейчас я хочу представить тезисы моего доклада, который я планировал представить на Третьей конференции «Свободное программное обеспечение в высшей школе». Доклад называется «Инициативы Google Summer of Code и Google Highly Open Participation Contest». К сожалению он не был одобрен оргкомитетом конференции, но я надеюсь что он будет интересен некоторым из моих читателей.