Difference between revisions of "Onboard Java Compiler"

From Gumstix User Wiki
Jump to: navigation, search
m (Installation)
m (Install phoneme jvm)
Line 36: Line 36:
 
  opkg install jikes
 
  opkg install jikes
  
=== Install phoneme jvm ===
+
== Install phoneme jvm ==
 
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm
 
If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm
 
  wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk
 
  wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk

Revision as of 03:54, 10 April 2011

To install a java vm , a compiler and runtime library.


Pre-requisites

Need to have these packages installed

task-native-sdk

opkg install task-native-sdk

Installation

As root on a running gumstix with internet access.

If you don't have internet access on your gumstix, you can download the packages and copy them to the gumstix via usb drive. May take a few goes to get all the dependencies.

first add angstrom repo

echo 'src/gz angstrom-base http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv7a/base'
> /etc/opkg/angstrom-base.conf

Install class path

opkg install classpath
opkg install classpath-dev  

If you need the graphical classes

opkg install classpath-gtk

If you are using graphical classes/gui remember to export the display

export DISPLAY=:0.0

Install cacao vm

opkg install cacao

Install jikes java compiler

opkg install jikes

Install phoneme jvm

If you need a java vm with debuging or remote debugging support or wish to use the phoneme jvm

wget http://bugcommunity.com/downloads/files/phoneme-advanced-personal-debug_mr2-r1_armv6.ipk
opkg install -force-depends phoneme-advanced-personal-debug_mr2-r1_armv6.ipk


Once you have installed it add cvm to your path or create a symbolic link cvm is in /usr/lib/jvm/phoneme-advanced-personal-debug/bin

sudo ln -s  /usr/lib/jvm/phoneme-advanced-personal-debug/bin/cvm /usr/bin/cvm

Set the classpath for Jikes

Set the bootclass path so jikes can find the classes

export BOOTCLASSPATH=/usr/share/cacao/vm.zip:/usr/share/classpath/glibj.zip

Testing the install

Once everything is installed and you are ready to run.

Check the versions

Check the versions and that the jvm's run.

First cacao

alxx@omap1:~$ java -version
java version "1.5.0"
CACAO version 0.99.4
Copyright (C) 1996-2005, 2006, 2007, 2008
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
alxx@omap1:~$ java -fullversion
java full version "cacao-1.5.0"

or

alxx@omap1:~$ cacao -fullversion
java full version "cacao-1.5.0"
alxx@omap1:~$ 

Then phoneme

alxx@omap1:~$ java-cdc -version
Product: phoneME Advanced (phoneme_advanced_mr2-b97)
Profile: Personal Profile Specification 1.1
JVM:     CVM phoneme_advanced_mr2-b97 (mixed mode)
alxx@omap1:~$ 

or

alxx@omap1:~$ cvm -version
Product: phoneME Advanced (phoneme_advanced_mr2-b97)
Profile: Personal Profile Specification 1.1
JVM:     CVM phoneme_advanced_mr2-b97 (mixed mode)
alxx@omap1:~$

Compile HelloWorld

Then with the standard java hello world

vim Hello.java
/* Hello.java */
public class Hello
{
  public static void main(String[] args)
  {
    System.out.println("Hello world!");
  }
}

Save then compile

alxx@omap1:~$ jikes Hello.java
alxx@omap1:~$ ls
Hello.class  Hello.java

Run the program

Run it using cacao

alxx@omap1:~$ java Hello
Hello world!
alxx@omap1:~$

or

alxx@omap1:~$ cacao Hello
Hello world!
alxx@omap1:~$


Run it using phoneme

alxx@omap1:~$ java-cdc Hello
Hello world!
alxx@omap1:~$

or

alxx@omap1:~$ cvm Hello
Hello world!
alxx@omap1:~$

Test phoneme using its provided testclasses.zip

alxx@omap1:~$cvm -cp /usr/lib/jvm/phoneme-advanced-personal-debug/testclasses.zip HelloWorld
Hello world.
alxx@omap1:~$


phoneme with some extra files can be used to run javascript , jython and servlets see http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug