world leader in high performance signal processing
Trace: » kaffe

Run Java application on stamp board

This section will describe how to setup a java runtime environment to run your java application. Now we select kaffe JVM as our java runtime environment.You can visit its official website to get more information.

Step by Step Instructions

Blackfin Source Code

  • First you want to make sure you have the latest sources from CVS for the toolchain and the kernel. For more information on this please refer to the CVS Quickstart.
  • Next you must build and install the toolchain. If you are unsure on how to do this please see buildscript.
  • After the toolchain has finished building you must add the toolchain to your PATH. Please refer to Setting the PATH Environment for more details.

Compile Blackfin Kernel

  • Next cd into the freshly downloaded kernel directory, uClinux-dist.
user@linux:~/checkouts/kernel/uClinux-dist> cd where/you/put/uClinux-dist
  • Now enter the command:
user@linux:~/checkouts/kernel/uClinux-dist> make clean
  • Next enter the following command to configure your kernel:
user@linux:~/checkouts/kernel/uClinux-dist> make menuconfig
  • In the make menuconfig menu select some required options.In fact, kaffe is not depend any library and special kernel features.

You may be asked to input some parameters during the make menuconfig or make procedures. If you are asked during these processes for any information simply hit enter to use the default values.

  • Now Save and Exit
  • When you get back to the command line. Issue a make to create the kernel image.
user@linux:~/checkouts/kernel/uClinux-dist> make

Boot New Kernel On The Board

  • After the make finishes, copy the linux image to your tftp directory. (For more information setting up a tftp server please see setting_up_a_tftp_server.)
user@linux:~/checkouts/kernel/uClinux-dist> cp ./images/linux /tftpboot/linux
  • Tftp the file to your target and boot the kernel using U-Boot. (For more information on using U-Boot please see u-boot.)
stamp> tftp 0x1000000 linux
stamp> bootelf

Host Java Setup

  • Because java library files is too large, we can not place the whole JVM into image.So we will transfer them by network after the uClinux is booted.You also can add some commands in /etc/rc script so that file transfer and enviorment setup can be executed automatically.

.Now we assume the uClinux system is booted normally and network work very well. The following is about how to compile the kaffe.

  • Before we cross-compile the kaffe, we need to compile jikes and kaffe natively and jikes should be compiled before kaffe. Download them from and your native compiler to compile them on your host.Assume we install them to /opt/jikes and /opt/kaffe separately. Download jikes-1.22.tar.bz2 package from jikes website,and extract the package, run following command:
./configure --prefix=/opt/jikes/
make install
export PATH=$PATH:/opt/jikes/bin

Download kaffe-1.1.7.tar.gz and extract the package, run the following command:

./configure --prefix=/opt/kaffe/
make install
export PATH=$PATH:/opt/kaffe/bin

Kaffe for Blackfin

  • Now unpack the kaffe source into a different directory.
  • Here is an example way to compile the source; feel free to tweak the configure options.
./configure \
	--host=bfin-uclinux \
	--disable-native-awt \
	--enable-pure-java-math \
	--with-gc=kaffe-gc \
	--with-threads=unix-pthreads \
	--enable-static \
	--with-staticlib \
	--with-staticbin \
	--with-staticvm \
	--disable-binreloc \
	--disable-alsa \
	--without-esd \

Then the whole build procedure begins…. After several minutes(due to the speed of your machine), kaffe compilation should be finished. At the same time, java class library is also compiled and located at libraries directory under kaffe source. For java application can run normally we should increase the stack size of kaffe-bin program. run the command:

bfin-uclinux-flthdr -s 1048576 -o kaffe.flt kaffe/kaffe/kaffe-bin

Now we need to transfer some files required by java application to stamp board by ftp or rcp program. Now we take a simple example that classic helloworld application written by java can run on the stamp board. We write the helloworld java program named,its content as the following:

class HelloWorldApp {
    public static void main(String[] args) {
        //Display "Hello World!"
        System.out.println("Hello World!");

Use any java compile to compile the program to java byte code file named HelloWorldApp.class.Take for an example by Sun java compiler in the following command:


Then transfer this class file to stamp board.Also we transfer the following files:

kaffe/kaffe/kaffe.flt from kaffe source of host machine to /bin of stamp board
libraries/clib/native/.libs/libnative.a from kaffe source of host machine to /var/lib of stamp board
libraries/clib/native/.libs/ from kaffe source of host machine to /var/lib of stamp board
libraries/clib/nio/.libs/libnio.a from kaffe source of host machine to /var/lib of stamp board
libraries/clib/nio/.libs/ from kaffe source of host machine to /var/lib of stamp board
libraries/clib/io/.libs/libio.a from kaffe source of host machine to /var/lib of stamp board
libraries/clib/io/.libs/ from kaffe source of host machine to /var/lib of stamp board
libraries/javalib/rt.jar from kaffe source of host machine to /var/lib of stamp board
libraries/javalib/tools.jar from kaffe source of host machine to /var/lib/ of stamp board

Then we need to setup some environment:

export KAFFELIBRARYPATH=/var/lib

All these step is done, we can run our HelloWorld application by type the command:

kaffe.flt -Xbootclasspath:/var/lib/rt.jar HelloWorldApp

You will see the output:

Hello World!

Know issues:

* Not all the java testcases under kaffe/test can run.I tried HelloWorld and file operation related testcases run normally,but some cases maybe fail.

* Sometimes java application will hang, you can kill it by Ctrl+C.