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 http://www.kaffe.org to get more information.
user@linux:~/checkouts/kernel/uClinux-dist> cd where/you/put/uClinux-dist
user@linux:~/checkouts/kernel/uClinux-dist> make clean
user@linux:~/checkouts/kernel/uClinux-dist> make menuconfig
user@linux:~/checkouts/kernel/uClinux-dist> make
user@linux:~/checkouts/kernel/uClinux-dist> cp ./images/linux /tftpboot/linux
stamp> tftp 0x1000000 linux stamp> bootelf
.Now we assume the uClinux system is booted normally and network work very well. The following is about how to compile the kaffe.
./configure --prefix=/opt/jikes/ make 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 make install export PATH=$PATH:/opt/kaffe/bin
./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 \ --with-engine=intrp make
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 HelloWorldApp.java,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:
javac HelloWorldApp.java
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/libnative.la 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/libnio.la 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/libio.la 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.