Difference between revisions of "Building JamVM and GNU Classpath and Jikes (for Java support in webOS) with scratchbox2"

From WebOS Internals
Jump to navigation Jump to search
m (→‎Building Gnu Classpath 0.99-CVS: add missing command line)
 
(8 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
Next install gcj needed for compiling Gnu Classpath
 
Next install gcj needed for compiling Gnu Classpath
 
  sudo apt-get install gcj
 
  sudo apt-get install gcj
 +
 +
Next install cvs needed for getting Gnu Classpath latest dev source code (0.99 in CVS)
 +
sudo apt-get install cvs
 +
 +
Next install cvs needed for getting escher latest dev source code (1.9.90 in Hg)
 +
sudo apt-get install mercurial
  
 
= Compiling =
 
= Compiling =
Line 22: Line 28:
 
== Create the folders ==
 
== Create the folders ==
  
 +
rm -Rf /usr/local/*
 
  mkdir -p /usr/local/bin/
 
  mkdir -p /usr/local/bin/
 
  mkdir -p /usr/local/include/
 
  mkdir -p /usr/local/include/
Line 27: Line 34:
 
  mkdir -p /usr/local/share/
 
  mkdir -p /usr/local/share/
 
or
 
or
 +
sudo rm -Rf /media/internal/*
 
  sudo mkdir -p /media/internal/opt
 
  sudo mkdir -p /media/internal/opt
 
  sudo chown -R ubuntu:ubuntu /media
 
  sudo chown -R ubuntu:ubuntu /media
Line 100: Line 108:
  
 
[http://marcosroriz.wordpress.com/2010/06/14/gsoc-updates/ Escher useful information here].
 
[http://marcosroriz.wordpress.com/2010/06/14/gsoc-updates/ Escher useful information here].
 
Escher download page : http://sourceforge.net/projects/escher/files/escher/0.3/ and http://escher.sourceforge.net/
 
  
 
Ant download page : http://archive.apache.org/dist/ant/binaries/ and http://ant.apache.org/bindownload.cgi
 
Ant download page : http://archive.apache.org/dist/ant/binaries/ and http://ant.apache.org/bindownload.cgi
Line 109: Line 115:
 
  gij (GNU libgcj) version 4.5.2
 
  gij (GNU libgcj) version 4.5.2
 
  ...
 
  ...
 +
 +
=== Building escher 0.3 ===
 +
 +
Escher download page : http://sourceforge.net/projects/escher/files/escher/0.3/ and http://escher.sourceforge.net/
  
 
  cd /home/ubuntu/java-project
 
  cd /home/ubuntu/java-project
Line 135: Line 145:
  
 
If you do not want to compile escher-0.3.jar, you can download [http://sourceforge.net/projects/escher/files/escher/0.3/ HERE], ready to use.
 
If you do not want to compile escher-0.3.jar, you can download [http://sourceforge.net/projects/escher/files/escher/0.3/ HERE], ready to use.
 +
 +
=== Building escher 1.9.90 ===
 +
 +
Escher source code : http://escher.hg.sourceforge.net:8000/hgroot/escher/escher and http://escher.sourceforge.net/
 +
 +
cd /home/ubuntu/java-project
 +
hg clone http://escher.hg.sourceforge.net:8000/hgroot/escher/escher escher-1.9.90
 +
wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.tar.gz
 +
tar xzvf apache-ant-1.7.1-bin.tar.gz
 +
export ANT_HOME=/home/ubuntu/java-project/apache-ant-1.7.1
 +
export PATH=$PATH:/home/ubuntu/java-project/apache-ant-1.7.1
 +
cd escher-1.9.90
 +
edit build.xml and replace the line
 +
<property name="version" value="0.3" />
 +
by
 +
<property name="version" value="1.9.90" />
 +
.
 +
ant -f build.xml clean
 +
ant -f build.xml dist
 +
 +
Go in ARM mode in your ScratchBox 2 :
 +
sb2 -M /srv/preware/cross-compile/staging/mapping-armv7
 +
 +
mkdir -p /usr/local/share/classpath/
 +
cp dist/escher-1.9.90.jar /usr/local/share/classpath/
 +
or
 +
mkdir -p /media/internal/opt/share/classpath/
 +
cp dist/escher-1.9.90.jar /media/internal/opt/share/classpath/
 +
 +
 +
Quit ScratchBox 2 :
 +
exit
  
 
== Install GNU Classpath ==
 
== Install GNU Classpath ==
Line 148: Line 190:
 
For compiling with sound support, ALSA libs are needed. For compiling with GUI support, X libs are needed AND Escher or QT or GTK libs. <BR>
 
For compiling with sound support, ALSA libs are needed. For compiling with GUI support, X libs are needed AND Escher or QT or GTK libs. <BR>
 
For low footprint memory, Escher is the best choice. [http://marcosroriz.wordpress.com/2010/06/14/gsoc-updates/ More useful information here]. <BR>
 
For low footprint memory, Escher is the best choice. [http://marcosroriz.wordpress.com/2010/06/14/gsoc-updates/ More useful information here]. <BR>
 +
 +
=== Building Gnu Classpath 0.98 ===
  
 
Patch for Gnu Classpath 0.98 with escher 0.3.0 : [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41057 X Awt peers to escher lib broken]
 
Patch for Gnu Classpath 0.98 with escher 0.3.0 : [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41057 X Awt peers to escher lib broken]
Line 195: Line 239:
 
'''Note 1''' : Here, we have the option --disable-plugin because the webkit web browser in webOS can use this java plugin. But maybe, this Java plugin can be used with [http://www.fractalbrew.com/labs/prefox/ PreFox web browser]. <BR>
 
'''Note 1''' : Here, we have the option --disable-plugin because the webkit web browser in webOS can use this java plugin. But maybe, this Java plugin can be used with [http://www.fractalbrew.com/labs/prefox/ PreFox web browser]. <BR>
 
'''Note 2''' : Here, we have the option --with-escher=/home/ubuntu/java-project/escher-0.3/src and NOT /usr/local/share/classpath because Gnu Classpath compile fine ONLY if he can find folder with the escher's java .class files and NOT the escher-0.3.jar <BR>
 
'''Note 2''' : Here, we have the option --with-escher=/home/ubuntu/java-project/escher-0.3/src and NOT /usr/local/share/classpath because Gnu Classpath compile fine ONLY if he can find folder with the escher's java .class files and NOT the escher-0.3.jar <BR>
 +
'''Note 3''' : Here, we have the option --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit because if the parameter enable-default-toolkit is not set , it will use gnu.java.awt.peer.gtk.GtkToolkit by default (compile with GTK support) (Source part "dnl Default AWT toolkit" in [http://cvs.savannah.gnu.org/viewvc/classpath/configure.ac?revision=1.249&root=classpath&view=markup the file HERE]) .
 +
 +
=== Building Gnu Classpath 0.99-CVS ===
 +
 +
Patch for Gnu Classpath 0.99 with escher 1.9.90 : [http://old.nabble.com/XPeer-%28~Escher%29-patch-td29168966.html  XPeer (~Escher) patch]
 +
 +
Compile :
 +
cd java-project
 +
 +
cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/classpath export -DNOW classpath
 +
mv classpath classpath-0.99
 +
 +
Here, we need to patch classpath-0.99 because it can not compile with escher-1.9.90 but only with the old escher-0.2.3
 +
Go to [http://old.nabble.com/XPeer-%28~Escher%29-patch-td29168966.html  XPeer (~Escher) patch], and copy in a patch_escher-1.9.90_with_gnu-classpath-0.99.patch, all the lines from
 +
### Eclipse Workspace Patch 1.0
 +
to
 +
ZPixmap getZPixmap()
 +
then next copy the patch_escher-1.9.90_with_gnu-classpath-0.99.patch file in classpath-0.99 folder
 +
$ cd classpath-0.99
 +
$ ./autogen.sh
 +
$ patch -p0 < patch_escher-1.9.90_with_gnu-classpath-0.99.patch
 +
patching file gnu/java/awt/peer/x/GLGraphics.java
 +
patching file gnu/java/awt/peer/x/KeyboardMapping.java
 +
patching file gnu/java/awt/peer/x/PixmapVolatileImage.java
 +
patching file gnu/java/awt/peer/x/XEventPump.java
 +
patching file gnu/java/awt/peer/x/XFontPeer.java
 +
patching file gnu/java/awt/peer/x/XFramePeer.java
 +
patching file gnu/java/awt/peer/x/XGraphics2D.java
 +
patching file gnu/java/awt/peer/x/XGraphicsConfiguration.java
 +
patching file gnu/java/awt/peer/x/XGraphicsDevice.java
 +
patching file gnu/java/awt/peer/x/XGraphicsEnvironment.java
 +
patching file gnu/java/awt/peer/x/XImage.java
 +
patching file gnu/java/awt/peer/x/XWindowPeer.java
 +
patching file gnu/java/awt/peer/x/ZPixmapDataBuffer.java
 +
Hunk #3 succeeded at 51 with fuzz 1.
 +
patching file gnu/java/awt/peer/x/GLGraphics.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
1 out of 1 hunk ignored -- saving rejects to file gnu/java/awt/peer/x/GLGraphics.java.rej
 +
patching file gnu/java/awt/peer/x/KeyboardMapping.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
3 out of 3 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/KeyboardMapping.java.rej
 +
patching file gnu/java/awt/peer/x/PixmapVolatileImage.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
4 out of 4 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/PixmapVolatileImage.java.rej
 +
patching file gnu/java/awt/peer/x/XEventPump.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
14 out of 14 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XEventPump.java.rej
 +
patching file gnu/java/awt/peer/x/XFontPeer.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
2 out of 2 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XFontPeer.java.rej
 +
patching file gnu/java/awt/peer/x/XFramePeer.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
1 out of 1 hunk ignored -- saving rejects to file gnu/java/awt/peer/x/XFramePeer.java.rej
 +
patching file gnu/java/awt/peer/x/XGraphics2D.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
12 out of 12 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XGraphics2D.java.rej
 +
patching file gnu/java/awt/peer/x/XGraphicsConfiguration.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
3 out of 3 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XGraphicsConfiguration.java.rej
 +
patching file gnu/java/awt/peer/x/XGraphicsDevice.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] nn
 +
Skipping patch.
 +
5 out of 5 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XGraphicsDevice.java.rej
 +
patching file gnu/java/awt/peer/x/XGraphicsEnvironment.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
2 out of 2 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XGraphicsEnvironment.java.rej
 +
patching file gnu/java/awt/peer/x/XImage.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
2 out of 2 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XImage.java.rej
 +
patching file gnu/java/awt/peer/x/XWindowPeer.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
7 out of 7 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XWindowPeer.java.rej
 +
patching file gnu/java/awt/peer/x/ZPixmapDataBuffer.java
 +
Reversed (or previously applied) patch detected!  Assume -R? [n] n
 +
Apply anyway? [n] n
 +
Skipping patch.
 +
3 out of 3 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/ZPixmapDataBuffer.java.rej
 +
-
 +
$ rm -Rf gnu/java/awt/peer/x/*.java.rej
 +
$ rm -Rf gnu/java/awt/peer/x/*.java.orig
 +
 +
Go in ARM mode in your ScratchBox 2 :
 +
sb2 -M /srv/preware/cross-compile/staging/mapping-armv7
 +
 +
Case 1 - Without GUI and sound support :
 +
./configure --prefix=/usr/local --disable-examples --without-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi
 +
make
 +
make install
 +
cd ..
 +
 +
Case 2 - With GUI and sound support :
 +
  LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --enable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-1.9.90/src --enable-local-sockets --enable-collections --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
 +
make
 +
make install
 +
cd ..
 +
 +
Case 3 - With GUI and sound and XMLJ support (XMLJ is used to parse XML files as web services, etc...) :
 +
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --enable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-1.9.90/src --enable-local-sockets --enable-collections --enable-xmlj --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
 +
make
 +
make install
 +
cd ..
 +
 +
Case 3b - Without sound and With GUI and XMLJ support (XMLJ is used to parse XML files as web services, etc...) :
 +
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/media/internal/opt/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/media/internal/opt --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-1.9.90/src --enable-local-sockets --enable-collections --enable-xmlj --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
 +
make
 +
make install
 +
cd ..
 +
 +
'''Note 1''' : Here, we have the option --disable-plugin because the webkit web browser in webOS can use this java plugin. But maybe, this Java plugin can be used with [http://www.fractalbrew.com/labs/prefox/ PreFox web browser]. <BR>
 +
'''Note 2''' : Here, we have the option --with-escher=/home/ubuntu/java-project/escher-1.9.90/src and NOT /usr/local/share/classpath because Gnu Classpath compile fine ONLY if he can find folder with the escher's java .class files and NOT the escher-0.3.jar <BR>
 
'''Note 3''' : Here, we have the option --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit because if the parameter enable-default-toolkit is not set , it will use gnu.java.awt.peer.gtk.GtkToolkit by default (compile with GTK support) (Source part "dnl Default AWT toolkit" in [http://cvs.savannah.gnu.org/viewvc/classpath/configure.ac?revision=1.249&root=classpath&view=markup the file HERE]) .
 
'''Note 3''' : Here, we have the option --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit because if the parameter enable-default-toolkit is not set , it will use gnu.java.awt.peer.gtk.GtkToolkit by default (compile with GTK support) (Source part "dnl Default AWT toolkit" in [http://cvs.savannah.gnu.org/viewvc/classpath/configure.ac?revision=1.249&root=classpath&view=markup the file HERE]) .
  
Line 450: Line 627:
 
  /usr/local/bin/jamvm  myfirstjavaprog
 
  /usr/local/bin/jamvm  myfirstjavaprog
 
or  
 
or  
  /usr/local/bin/jamvm -client -classpath/usr/local/share/jamvm/classes.zip:/usr/local/share/classpath/glibj.zip myfirstjavaprog
+
  /usr/local/bin/jamvm -client -Xbootclasspath:/usr/local/share/jamvm/classes.zip:/usr/local/share/classpath/glibj.zip myfirstjavaprog
 
and you can see :
 
and you can see :
 
  Hello World!
 
  Hello World!
Line 526: Line 703:
 
To test X Awt peer, you must remove "-nolisten TCP" from XServer start script. ([http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41057 Source]) and in console type the command line xhost+ ([http://rbytes.net/linux/escher-review/ source]) .
 
To test X Awt peer, you must remove "-nolisten TCP" from XServer start script. ([http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41057 Source]) and in console type the command line xhost+ ([http://rbytes.net/linux/escher-review/ source]) .
  
  /usr/local/bin/jamvm HelloWorld -bootclasspath /media/internal/opt/share/jamvm/classes.zip:/media/internal/opt/share/classpath/glibj.zip:/media/internal/opt/share/classpath/escher-0.3.jar:/media/internal/opt/share/classpath/collections.jar HelloWorld -Dawt.toolkit=gnu.java.awt.peer.x.XToolkit HelloWorld
+
  /usr/local/bin/jamvm -Xbootclasspath:/media/internal/opt/share/jamvm/classes.zip:/media/internal/opt/share/classpath/glibj.zip:/media/internal/opt/share/classpath/escher-0.3.jar:/media/internal/opt/share/classpath/collections.jar -Dawt.toolkit=gnu.java.awt.peer.x.XToolkit HelloWorld
 
or  
 
or  
  /media/internal/opt/bin/jamvm HelloWorld -bootclasspath /media/internal/opt/share/jamvm/classes.zip:/media/internal/opt/share/classpath/glibj.zip:/media/internal/opt/share/classpath/escher-0.3.jar:/media/internal/opt/share/classpath/collections.jar HelloWorld -Dawt.toolkit=gnu.java.awt.peer.x.XToolkit HelloWorld
+
  /media/internal/opt/bin/jamvm -Xbootclasspath:/media/internal/opt/share/jamvm/classes.zip:/media/internal/opt/share/classpath/glibj.zip:/media/internal/opt/share/classpath/escher-0.3.jar:/media/internal/opt/share/classpath/collections.jar -Dawt.toolkit=gnu.java.awt.peer.x.XToolkit HelloWorld
  
 
and you can see a GUI window :
 
and you can see a GUI window :
Line 793: Line 970:
 
JDK6 for embedded ARM
 
JDK6 for embedded ARM
 
http://mail.openjdk.java.net/pipermail/jdk6-dev/2009-April/000455.html
 
http://mail.openjdk.java.net/pipermail/jdk6-dev/2009-April/000455.html
 +
 +
Simple Swing Tests with OpenJDK/Classpath/Classpath+Escher
 +
http://old.nabble.com/Simple-Swing-Tests-with-OpenJDK-Classpath-Classpath%2BEscher-td28605374.html

Latest revision as of 11:04, 21 January 2012

'NOTE : 02/01/2012 : Jikes, the Java compiler works and compile a basic HelloWorld java program with success,
06/01/2012 : JamVM (JRE/Java runtime) works with a HelloWorld java program in text mode in a console !!!
Next steps : Have a Hello World java program with AWT GUI in a X window that works with JamVM JRE, and next have sound with JamVM JRE'

Requirements

First, follow the tutorial WebOS Internals PDK to set up the cross compilation environment.

Next install gcj needed for compiling Gnu Classpath

sudo apt-get install gcj

Next install cvs needed for getting Gnu Classpath latest dev source code (0.99 in CVS)

sudo apt-get install cvs

Next install cvs needed for getting escher latest dev source code (1.9.90 in Hg)

sudo apt-get install mercurial

Compiling

Create your working folder :

cd /home/ubuntu
mkdir java-project
cd java-project

Go in ARM mode in your ScratchBox 2 :

sb2 -M /srv/preware/cross-compile/staging/mapping-armv7

Create the folders

rm -Rf /usr/local/*
mkdir -p /usr/local/bin/
mkdir -p /usr/local/include/
mkdir -p /usr/local/lib/
mkdir -p /usr/local/share/

or

sudo rm -Rf /media/internal/*
sudo mkdir -p /media/internal/opt
sudo chown -R ubuntu:ubuntu /media
mkdir -p /media/internal/opt/bin/
mkdir -p /media/internal/opt/include/
mkdir -p /media/internal/opt/lib/
mkdir -p /media/internal/opt/share/

Quit ScratchBox 2 :

exit

Install Zlib needed by JamVM and LibXML2

Go in ARM mode in your ScratchBox 2 :

sb2 -M /srv/preware/cross-compile/staging/mapping-armv7
cd /srv/preware/cross-compile/packages/common
rm -Rf /srv/preware/cross-compile/packages/common/zlib/build
make -C zlib ARCH=armv7 stage

Quit ScratchBox 2 :

exit

Install LibXML et LibXSLT needed to create libxmlj by Gnu Classpath (optionnal - only for XML parsing support as with web services)

GNU Classpath 0.98 need libxml-2.0 >= 2.6.8 and libxslt >= 1.1.11 . Then we choose LibXML 2.6.26 and LibXSLT 1.1.17 with the same release date 06/06/2006

Note : Do not use LibXML 2.6.26 in /srv/preware/cross-compile/packages/common/libxml2 or http://git.webos-internals.org/preware/cross-compile/tree/packages/common/libxml2
because the Makefile use install-pkgconfigDATA and make install in include folder (install only files in include and lib folders but not in bin folder).
The problem is that LibXSLT's configure want to find the file /usr/local/bin/xml2-config

Go in ARM mode in your ScratchBox 2 :

sb2 -M /srv/preware/cross-compile/staging/mapping-armv7

LibXML 2.6.26 :

cd /home/ubuntu/java-project
wget ftp://xmlsoft.org/libxml2/old/libxml2-2.6.26.tar.gz
tar xzvf libxml2-2.6.26.tar.gz
cd libxml2-2.6.26
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --with-zlib=/usr/local
make 
make install
cd ..

LibXSLT 1.1.17 :

cd /home/ubuntu/java-project
wget ftp://xmlsoft.org/libxml2/old/libxslt-1.1.17.tar.gz
tar xzvf libxslt-1.1.17.tar.gz
cd libxslt-1.1.17
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --with-libxml-prefix=/usr/local
make
make install
cd ..

Quit ScratchBox 2 :

exit

Install Alsa needed by Gnu Classpath (optionnal - only for GUI mode with sound)

cd /srv/preware/cross-compile/packages/media
rm -Rf /srv/preware/cross-compile/packages/media/alsa-lib/build
make -C alsa-lib ARCH=armv7 stage

Install X needed by Gnu Classpath (optionnal - only for GUI mode)

cd /srv/preware/cross-compile/packages/x
rm -Rf /srv/preware/cross-compile/packages/x/libx11/build
make -C libx11 ARCH=armv7 stage

Install Escher needed by Gnu Classpath (optionnal - only for GUI mode)

Goal : bridge between Java and X server

Escher useful information here.

Ant download page : http://archive.apache.org/dist/ant/binaries/ and http://ant.apache.org/bindownload.cgi

$ java -version
java version "1.5.0"
gij (GNU libgcj) version 4.5.2
...

Building escher 0.3

Escher download page : http://sourceforge.net/projects/escher/files/escher/0.3/ and http://escher.sourceforge.net/

cd /home/ubuntu/java-project
wget http://heanet.dl.sourceforge.net/project/escher/escher/0.3/escher-0.3.tar.gz
wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.tar.gz
tar xzvf escher-0.3.tar.gz
tar xzvf apache-ant-1.7.1-bin.tar.gz
export ANT_HOME=/home/ubuntu/java-project/apache-ant-1.7.1
export PATH=$PATH:/home/ubuntu/java-project/apache-ant-1.7.1
cd escher-0.3
ant -f build.xml clean
ant -f build.xml dist

Go in ARM mode in your ScratchBox 2 :

sb2 -M /srv/preware/cross-compile/staging/mapping-armv7
mkdir -p /usr/local/share/classpath/
cp dist/escher-0.3.jar /usr/local/share/classpath/

or

mkdir -p /media/internal/opt/share/classpath/
cp dist/escher-0.3.jar /media/internal/opt/share/classpath/


Quit ScratchBox 2 :

exit

If you do not want to compile escher-0.3.jar, you can download HERE, ready to use.

Building escher 1.9.90

Escher source code : http://escher.hg.sourceforge.net:8000/hgroot/escher/escher and http://escher.sourceforge.net/

cd /home/ubuntu/java-project
hg clone http://escher.hg.sourceforge.net:8000/hgroot/escher/escher escher-1.9.90
wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.tar.gz
tar xzvf apache-ant-1.7.1-bin.tar.gz
export ANT_HOME=/home/ubuntu/java-project/apache-ant-1.7.1
export PATH=$PATH:/home/ubuntu/java-project/apache-ant-1.7.1
cd escher-1.9.90

edit build.xml and replace the line

<property name="version" value="0.3" />

by

<property name="version" value="1.9.90" />

.

ant -f build.xml clean
ant -f build.xml dist

Go in ARM mode in your ScratchBox 2 :

sb2 -M /srv/preware/cross-compile/staging/mapping-armv7
mkdir -p /usr/local/share/classpath/
cp dist/escher-1.9.90.jar /usr/local/share/classpath/

or

mkdir -p /media/internal/opt/share/classpath/
cp dist/escher-1.9.90.jar /media/internal/opt/share/classpath/


Quit ScratchBox 2 :

exit

Install GNU Classpath

Goal : implement almost all of the classes from Java J2SE 1.4 and 5.0.

GNU Classpath at Wikipedia : http://en.wikipedia.org/wiki/GNU_Classpath

GNU Classpath download page / website : http://www.gnu.org/software/classpath/downloads/downloads.html and http://www.gnu.org/software/classpath/

Note: here, Gnu Classpath is only compiled for working in console mode. No support for sound or GUI in Java programs. The extra libs needed for these supports are detailed here : http://www.gnu.org/software/classpath/docs/hacking.html#SEC5
For compiling with sound support, ALSA libs are needed. For compiling with GUI support, X libs are needed AND Escher or QT or GTK libs.
For low footprint memory, Escher is the best choice. More useful information here.

Building Gnu Classpath 0.98

Patch for Gnu Classpath 0.98 with escher 0.3.0 : X Awt peers to escher lib broken

Compile :

cd java-project
wget ftp://ftp.gnu.org/gnu/classpath/classpath-0.98.tar.gz
tar xzvf classpath-0.98.tar.gz

Here, we need to patch classpath-0.98 because it can not compile with escher-0.3 but only the old escher-0.2.3

wget http://gcc.gnu.org/bugzilla/attachment.cgi?id=18352
mv "attachment.cgi?id=18352" patch_escher-0.3_with_gnu-classpath-0.98.patch
$ patch -p0 < patch_escher-0.3_with_gnu-classpath-0.98.patch
patching file classpath-0.98/gnu/java/awt/peer/x/GLGraphics.java
patching file classpath-0.98/gnu/java/awt/peer/x/XEventPump.java
patching file classpath-0.98/gnu/java/awt/peer/x/XGraphicsDevice.java
cd classpath-0.98

Go in ARM mode in your ScratchBox 2 :

sb2 -M /srv/preware/cross-compile/staging/mapping-armv7

Case 1 - Without GUI and sound support :

./configure --prefix=/usr/local --disable-examples --without-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi
make
make install
cd ..

Case 2 - With GUI and sound support :

 LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --enable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-0.3/src --enable-local-sockets --enable-collections --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
make
make install
cd ..

Case 3 - With GUI and sound and XMLJ support (XMLJ is used to parse XML files as web services, etc...) :

LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --enable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-0.3/src --enable-local-sockets --enable-collections --enable-xmlj --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
make
make install
cd ..

Case 3b - Without sound and With GUI and XMLJ support (XMLJ is used to parse XML files as web services, etc...) :

LDFLAGS="-L/usr/local/lib -Wl,-rpath=/media/internal/opt/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/media/internal/opt --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-0.3/src --enable-local-sockets --enable-collections --enable-xmlj --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
make
make install
cd ..

Note 1 : Here, we have the option --disable-plugin because the webkit web browser in webOS can use this java plugin. But maybe, this Java plugin can be used with PreFox web browser.
Note 2 : Here, we have the option --with-escher=/home/ubuntu/java-project/escher-0.3/src and NOT /usr/local/share/classpath because Gnu Classpath compile fine ONLY if he can find folder with the escher's java .class files and NOT the escher-0.3.jar
Note 3 : Here, we have the option --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit because if the parameter enable-default-toolkit is not set , it will use gnu.java.awt.peer.gtk.GtkToolkit by default (compile with GTK support) (Source part "dnl Default AWT toolkit" in the file HERE) .

Building Gnu Classpath 0.99-CVS

Patch for Gnu Classpath 0.99 with escher 1.9.90 : XPeer (~Escher) patch

Compile :

cd java-project

cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/classpath export -DNOW classpath
mv classpath classpath-0.99

Here, we need to patch classpath-0.99 because it can not compile with escher-1.9.90 but only with the old escher-0.2.3 Go to XPeer (~Escher) patch, and copy in a patch_escher-1.9.90_with_gnu-classpath-0.99.patch, all the lines from

### Eclipse Workspace Patch 1.0 

to

ZPixmap getZPixmap()

then next copy the patch_escher-1.9.90_with_gnu-classpath-0.99.patch file in classpath-0.99 folder

$ cd classpath-0.99
$ ./autogen.sh 
$ patch -p0 < patch_escher-1.9.90_with_gnu-classpath-0.99.patch
patching file gnu/java/awt/peer/x/GLGraphics.java
patching file gnu/java/awt/peer/x/KeyboardMapping.java
patching file gnu/java/awt/peer/x/PixmapVolatileImage.java
patching file gnu/java/awt/peer/x/XEventPump.java
patching file gnu/java/awt/peer/x/XFontPeer.java
patching file gnu/java/awt/peer/x/XFramePeer.java
patching file gnu/java/awt/peer/x/XGraphics2D.java
patching file gnu/java/awt/peer/x/XGraphicsConfiguration.java
patching file gnu/java/awt/peer/x/XGraphicsDevice.java
patching file gnu/java/awt/peer/x/XGraphicsEnvironment.java
patching file gnu/java/awt/peer/x/XImage.java
patching file gnu/java/awt/peer/x/XWindowPeer.java
patching file gnu/java/awt/peer/x/ZPixmapDataBuffer.java
Hunk #3 succeeded at 51 with fuzz 1.
patching file gnu/java/awt/peer/x/GLGraphics.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file gnu/java/awt/peer/x/GLGraphics.java.rej
patching file gnu/java/awt/peer/x/KeyboardMapping.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
3 out of 3 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/KeyboardMapping.java.rej
patching file gnu/java/awt/peer/x/PixmapVolatileImage.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
4 out of 4 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/PixmapVolatileImage.java.rej
patching file gnu/java/awt/peer/x/XEventPump.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
14 out of 14 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XEventPump.java.rej
patching file gnu/java/awt/peer/x/XFontPeer.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XFontPeer.java.rej
patching file gnu/java/awt/peer/x/XFramePeer.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file gnu/java/awt/peer/x/XFramePeer.java.rej
patching file gnu/java/awt/peer/x/XGraphics2D.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
12 out of 12 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XGraphics2D.java.rej
patching file gnu/java/awt/peer/x/XGraphicsConfiguration.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
3 out of 3 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XGraphicsConfiguration.java.rej
patching file gnu/java/awt/peer/x/XGraphicsDevice.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] nn
Skipping patch.
5 out of 5 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XGraphicsDevice.java.rej
patching file gnu/java/awt/peer/x/XGraphicsEnvironment.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XGraphicsEnvironment.java.rej
patching file gnu/java/awt/peer/x/XImage.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XImage.java.rej
patching file gnu/java/awt/peer/x/XWindowPeer.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
7 out of 7 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/XWindowPeer.java.rej
patching file gnu/java/awt/peer/x/ZPixmapDataBuffer.java
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
3 out of 3 hunks ignored -- saving rejects to file gnu/java/awt/peer/x/ZPixmapDataBuffer.java.rej
-
$ rm -Rf gnu/java/awt/peer/x/*.java.rej
$ rm -Rf gnu/java/awt/peer/x/*.java.orig

Go in ARM mode in your ScratchBox 2 :

sb2 -M /srv/preware/cross-compile/staging/mapping-armv7

Case 1 - Without GUI and sound support :

./configure --prefix=/usr/local --disable-examples --without-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi
make
make install
cd ..

Case 2 - With GUI and sound support :

 LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --enable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-1.9.90/src --enable-local-sockets --enable-collections --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
make
make install
cd ..

Case 3 - With GUI and sound and XMLJ support (XMLJ is used to parse XML files as web services, etc...) :

LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --enable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-1.9.90/src --enable-local-sockets --enable-collections --enable-xmlj --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
make
make install
cd ..

Case 3b - Without sound and With GUI and XMLJ support (XMLJ is used to parse XML files as web services, etc...) :

LDFLAGS="-L/usr/local/lib -Wl,-rpath=/media/internal/opt/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/media/internal/opt --disable-examples --with-x --disable-qt-peer --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-alsa --disable-dssi --with-escher=/home/ubuntu/java-project/escher-1.9.90/src --enable-local-sockets --enable-collections --enable-xmlj --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit
make
make install
cd ..

Note 1 : Here, we have the option --disable-plugin because the webkit web browser in webOS can use this java plugin. But maybe, this Java plugin can be used with PreFox web browser.
Note 2 : Here, we have the option --with-escher=/home/ubuntu/java-project/escher-1.9.90/src and NOT /usr/local/share/classpath because Gnu Classpath compile fine ONLY if he can find folder with the escher's java .class files and NOT the escher-0.3.jar
Note 3 : Here, we have the option --enable-default-toolkit=gnu.java.awt.peer.x.XToolkit because if the parameter enable-default-toolkit is not set , it will use gnu.java.awt.peer.gtk.GtkToolkit by default (compile with GTK support) (Source part "dnl Default AWT toolkit" in the file HERE) .

Install libffi needed by JamVM

Note : You have segmentation fault with JamVM if you not compile it with libffi. More info about this segmentation fault problem in this thread.

libffi download page / website : http://sourceware.org/libffi/

cd /home/ubuntu/java-project
wget ftp://sourceware.org/pub/libffi/libffi-3.0.10.tar.gz
tar xzvf libffi-3.0.10.tar.gz
cd libffi-3.0.10
./configure --prefix=/usr/local --with-gcc-arch=armv7
make
make install
cp include/ffi_common.h /usr/local/include
cp arm-unknown-linux-gnueabi/include/ffi.h /usr/local/include
cp src/arm/ffitarget.h /usr/local/include
cd ..

or

cd /home/ubuntu/java-project
wget ftp://sourceware.org/pub/libffi/libffi-3.0.10.tar.gz
tar xzvf libffi-3.0.10.tar.gz
cd libffi-3.0.10
./configure --prefix=/media/internal/opt --with-gcc-arch=armv7
make
make install
cp include/ffi_common.h /media/internal/opt/include
cp arm-unknown-linux-gnueabi/include/ffi.h /media/internal/opt/include
cp src/arm/ffitarget.h /media/internal/opt/include
cd ..

Install JamVM

Goal : can launch Java program

JamVM at Wikipedia : http://en.wikipedia.org/wiki/JamVM

JamVM download page / website : http://sourceforge.net/projects/jamvm/files/jamvm/JamVM%201.5.4/ and http://jamvm.sourceforge.net/

cd /home/ubuntu/java-project
wget http://freefr.dl.sourceforge.net/project/jamvm/jamvm/JamVM%201.5.4/jamvm-1.5.4.tar.gz
tar xzvf jamvm-1.5.4.tar.gz
cd jamvm-1.5.4
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_RUN_LIBRARY_PATH=$LD_RUN_LIBRARY_PATH:/usr/local/lib
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --prefix=/usr/local --with-classpath-install-dir=/usr/local --enable-ffi
make
make install
cd ..

or

cd /home/ubuntu/java-project
wget http://freefr.dl.sourceforge.net/project/jamvm/jamvm/JamVM%201.5.4/jamvm-1.5.4.tar.gz
tar xzvf jamvm-1.5.4.tar.gz
cd jamvm-1.5.4
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/media/internal/opt/lib
export LD_RUN_LIBRARY_PATH=$LD_RUN_LIBRARY_PATH:/usr/local/lib:/media/internal/opt/lib
LDFLAGS="-L/usr/local/lib -L/media/internal/opt/lib -Wl,-rpath=/media/internal/opt/lib" CPPFLAGS="-I/usr/local/include -I/media/internal/opt/include" ./configure --prefix=/media/internal/opt --with-classpath-install-dir=/media/internal/opt -enable-ffi
make
make install
cd ..

Note 1 : do not use CFLAGS parameter to compile JamVM, there is maybe a problem (segmentation fault) with this parameter as you can find it in this post.

Install Jikes

Goal : can compile Java program

Jikes at Wikipedia : http://en.wikipedia.org/wiki/Jikes

download page / website : http://sourceforge.net/projects/jikes/files/ and http://jikes.sourceforge.net/

wget http://freefr.dl.sourceforge.net/project/jikes/Jikes/1.22/jikes-1.22.tar.bz2
bzip2 -d jikes-1.22.tar.bz2
tar xvf jikes-1.22.tar
cd jikes-1.22 
./configure --prefix=/usr/local
make
make install
cd ..

or

wget http://freefr.dl.sourceforge.net/project/jikes/Jikes/1.22/jikes-1.22.tar.bz2
bzip2 -d jikes-1.22.tar.bz2
tar xvf jikes-1.22.tar
cd jikes-1.22 
./configure --prefix=/media/internal/opt
make
make install
cd ..

Quit Scratch Box : exit

Installing the files on your device

cd /srv/preware/cross-compile/staging/armv7/usr
sudo chown -R root:root *
sudo tar cvf local.tar *
copy the local.tar on your webos device connected as USB key on your computer

or

cd /media/internal
sudo chown -R root:root *
sudo tar cvf opt.tar opt
copy the opt.tar on your webos device connected as USB key on your computer

On your computer connect at your webOS device

novacom -t open tty://

Move the files in the good folders :

cd /media/internal
mkdir java-project
mv local.tar java-project
cd java-project
tar Pxvf local.tar
chmod -R 755 *
chown root:root *
cd bin
cp -p * /usr/local/bin
cp -p -r include lib man share /usr/local

Fix missing symbolic links :

cd /usr/local/lib
ln -s libjvm.so.0.0.0 libjvm.so
ln -s libjvm.so.0.0.0 libjvm.so.0
ln -s libz.so.1.2.3 libz.so
ln -s libz.so.1.2.3 libz.so.1
ln -s libffi.so.5.0.10 libffi.so.5.0
ln -s libffi.so.5.0.10 libffi.so.5
ln -s libffi.so.5.0.10 libffi.so
ln -s /usr/local/share/classpath/glibj.zip rt.jar
cd classpath
ln -s libjavaio.so.0.0.0 libjavaio.so
ln -s libjavaio.so.0.0.0 libjavaio.so.0
ln -s libjavalangmanagement.so.0.0.0 libjavalangmanagement.so
ln -s libjavalangmanagement.so.0.0.0 libjavalangmanagement.so.0
ln -s libjavalangreflect.so.0.0.0 libjavalangreflect.so
ln -s libjavalangreflect.so.0.0.0 libjavalangreflect.so.0
ln -s libjavalang.so.0.0.0 libjavalang.so
ln -s libjavalang.so.0.0.0 libjavalang.so.0
ln -s libjavanet.so.0.0.0 libjavanet.so
ln -s libjavanet.so.0.0.0 libjavanet.so.0
ln -s libjavanio.so.0.0.0 libjavanio.so
ln -s libjavanio.so.0.0.0 libjavanio.so.0
ln -s libjavautil.so.0.0.0 libjavautil.so
ln -s libjavautil.so.0.0.0 libjavautil.so.0

or

cd /media/internal
mv opt.tar /media/internal
tar Pxvf opt.tar
chmod -R 755 opt
chown root:root opt

Fix missing symbolic links (note symbolic links with ln -s are not possible in this file system/folder):

cd /media/internal/opt/lib
cp -p libjvm.so.0.0.0 libjvm.so
cp -p libjvm.so.0.0.0 libjvm.so.0
cp -p libffi.so.5.0.10 libffi.so.5.0
cp -p libffi.so.5.0.10 libffi.so.5
cp -p libffi.so.5.0.10 libffi.so
cp -p /media/internal/opt/share/classpath/glibj.zip rt.jar
cd classpath
cp -p libjavaio.so.0.0.0 libjavaio.so
cp -p libjavaio.so.0.0.0 libjavaio.so.0
cp -p libjavalangmanagement.so.0.0.0 libjavalangmanagement.so
cp -p libjavalangmanagement.so.0.0.0 libjavalangmanagement.so.0
cp -p libjavalangreflect.so.0.0.0 libjavalangreflect.so
cp -p libjavalangreflect.so.0.0.0 libjavalangreflect.so.0
cp -p libjavalang.so.0.0.0 libjavalang.so
cp -p libjavalang.so.0.0.0 libjavalang.so.0
cp -p libjavanet.so.0.0.0 libjavanet.so
cp -p libjavanet.so.0.0.0 libjavanet.so.0
cp -p libjavanio.so.0.0.0 libjavanio.so
cp -p libjavanio.so.0.0.0 libjavanio.so.0
cp -p libjavautil.so.0.0.0 libjavautil.so
cp -p libjavautil.so.0.0.0 libjavautil.so.0
cp -p libxmlj.so.0.0.0 libxmlj.so
cp -p libxmlj.so.0.0.0 libxmlj.so.0

Basic testing for the main binaries

JamVM

# /usr/local/bin/jamvm -version

or

# /media/internal/opt/bin/jamvm -version
java version "1.5.0"
JamVM version 1.5.4
Copyright (C) 2003-2010 Robert Lougher <rob@jamvm.org.uk>
-
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2,
or (at your option) any later version.
-
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
-
Build information:
Execution Engine: inline-threaded interpreter with stack-caching
Compiled with: gcc 4.2.1
Boot Library Path: /usr/local/lib/classpath
Boot Class Path: /usr/local/share/jamvm/classes.zip:/usr/local/share/classpath/glibj.zip

Jikes

# /usr/local/bin/jikes -version

or

# /media/internal/opt/bin/jikes -version
Jikes Compiler - Version 1.22 - 3 October 2004
Copyright (C) IBM Corporation 1997-2003, 2004.
- Licensed Materials - Program Property of IBM - All Rights Reserved.
Originally written by Philippe Charles and David Shields of IBM Research,
Jikes is now maintained and refined by the Jikes Project at:
<http://ibm.com/developerworks/opensource/jikes>
Please consult this URL for more information and for reporting problems.

Compiling and Running a HelloWorld Java Program

console text mode

Compiling

For this example, I use a novacom connexion on my Palm Pre.

cd /media/internal
vi myfirstjavaprog.java 

and add the following lines in the myfirstjavaprog.java (source) :

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

Compile :

# /usr/local/bin/jikes -bootclasspath /usr/local/share/jamvm/classes.zip:/usr/local/share/classpath/glibj.zip myfirstjavaprog.java
ls -l 
...
-rwxrwxrwx    1 root     root           440 Jan  2 14:38 myfirstjavaprog.class
...

Running

/usr/local/bin/jamvm  myfirstjavaprog

or

/usr/local/bin/jamvm -client -Xbootclasspath:/usr/local/share/jamvm/classes.zip:/usr/local/share/classpath/glibj.zip myfirstjavaprog

and you can see :

Hello World!

GUI mode

Requirements for working

  • You need to install Xterm and Xecutah applications and to REBOOT your webOS device.
  • You need to have an .Xauthority file on your webOS device (detailed steps on your Linux computer / not webOS device ) :
mv .Xauthority .Xauthority.OLD
mkxauth -c localhost
mkxauth -c 127.0.0.1
xauth list
  localhost/unix:0  MIT-MAGIC-COOKIE-1  02bab2e14519a798471b74a19a5557d6
  localhost:0  MIT-MAGIC-COOKIE-1  055c66aab6ce789758499d026a8b236d
  127.0.0.1/unix:0  MIT-MAGIC-COOKIE-1  055c66aab6ce789758499d026a8b236d
mv .Xauthority .Xauthority.NEW
mv .Xauthority.OLD .Xauthority

Copy the .Xauthority.NEW file on your webOS device as USB drive

mv .Xauthority.NEW /media/internal
cp -p .Xauthority.NEW /var/home/root/.Xauthority
chown root:root /var/home/root/.Xauthority
chmod 644 /var/home/root/.Xauthority

Compiling

For this example, I use a novacom connexion on my Palm Pre.

cd /media/internal
vi HelloWorld.java 

and add the following lines in the HelloWorld.java (source) :

import java.awt.*;
import java.awt.event.*;
public class HelloWorld extends Frame {
   public static void main (String [] argv){
      HelloWorld h = new HelloWorld();
   }
   public HelloWorld(){
     setTitle("Hello World!");
     setSize(150, 125);
     Panel hello = new Panel();
     add("Center", hello);
     Button button = new Button("OK");
     add("South", button);
     button.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            System.exit(0);
         }
       });
     setVisible(true);
     int width = hello.getWidth();
     int height = hello.getHeight();
     Graphics g = hello.getGraphics();
     g.drawString("Hello World!", width/2 - 25, height/2);
     addWindowListener(new WindowAdapter(){
          public void windowClosing(WindowEvent e){ 
              System.exit(0);
          }
     });
   }
}

Compile :

# /usr/local/bin/jikes -bootclasspath /usr/local/share/jamvm/classes.zip:/usr/local/share/classpath/glibj.zip HelloWorld.java
ls -l 
...
-rwxrwxrwx    1 root     root           440 Jan  2 14:38 HelloWorld.class
...

Running

  • Launch Xcecutah app, and launch Xterm in your Xcecutah app.
  • Check that the /var/home/root/.Xauthority file is created on your webOPS device.

To test X Awt peer, you must remove "-nolisten TCP" from XServer start script. (Source) and in console type the command line xhost+ (source) .

/usr/local/bin/jamvm -Xbootclasspath:/media/internal/opt/share/jamvm/classes.zip:/media/internal/opt/share/classpath/glibj.zip:/media/internal/opt/share/classpath/escher-0.3.jar:/media/internal/opt/share/classpath/collections.jar -Dawt.toolkit=gnu.java.awt.peer.x.XToolkit HelloWorld

or

/media/internal/opt/bin/jamvm -Xbootclasspath:/media/internal/opt/share/jamvm/classes.zip:/media/internal/opt/share/classpath/glibj.zip:/media/internal/opt/share/classpath/escher-0.3.jar:/media/internal/opt/share/classpath/collections.jar -Dawt.toolkit=gnu.java.awt.peer.x.XToolkit HelloWorld

and you can see a GUI window :

Hello World!

Common error :

java.net.ConnectException: Connection refused
at gnu.java.nio.VMChannel.connect(Native Method)
...
at HelloWorld.main(HelloWorld.java:5)
Exception in thread "main" java.lang.NullPointerException
at gnu.x11.Display.init_streams(Display.java:1177)
...

--> Xcetah and Xterm apps are not launched

Can't find Xauthority file: /home/root/.Xauthority
java.net.UnknownHostException: John KENNEDY - Palm Pre
at java.net.VMInetAddress.getHostByName(Native Method)
...
at HelloWorld.main(HelloWorld.java:5)
Exception in thread "main" java.lang.ClassCastException: [B
at gnu.x11.Window.change_property(Window.java:742)
...

--> The file /home/root/.Xauthority is not created

java.net.UnknownHostException: John KENNEDY - Palm Pre
at java.net.VMInetAddress.getHostByName(Native Method)
...
at HelloWorld.main(HelloWorld.java:5)
Exception in thread "main" java.lang.ClassCastException: [B
  at gnu.x11.Window.change_property(Window.java:742)

--> Your webOS device use your name and the name of your webOS as host name. Need to change this name by localhost. The fix ???
THE FIX (SOURCE):
Check :

#hostname
John KENNEDY - Palm Pre

Modify :

#hostname localhost

Check :

#hostname
localhost

Audio mode

Playing Audio in Java

Files installed by each program

Gnu Classpath

[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/bin
total 52
-rwxr-xr-x 1 ubuntu ubuntu 2073 2012-01-01 19:23 gappletviewer
-rwxr-xr-x 1 ubuntu ubuntu 2058 2012-01-01 19:23 gjar
-rwxr-xr-x 1 ubuntu ubuntu 2070 2012-01-01 19:23 gjarsigner
-rwxr-xr-x 1 ubuntu ubuntu 2062 2012-01-01 19:23 gjavah
-rwxr-xr-x 1 ubuntu ubuntu 2113 2012-01-01 19:23 gjdoc
-rwxr-xr-x 1 ubuntu ubuntu 2066 2012-01-01 19:23 gkeytool
-rwxr-xr-x 1 ubuntu ubuntu 2084 2012-01-01 19:23 gnative2ascii
-rwxr-xr-x 1 ubuntu ubuntu 2060 2012-01-01 19:23 gorbd
-rwxr-xr-x 1 ubuntu ubuntu 2060 2012-01-01 19:23 grmic
-rwxr-xr-x 1 ubuntu ubuntu 2060 2012-01-01 19:23 grmid
-rwxr-xr-x 1 ubuntu ubuntu 2074 2012-01-01 19:23 grmiregistry
-rwxr-xr-x 1 ubuntu ubuntu 2075 2012-01-01 19:23 gserialver
-rwxr-xr-x 1 ubuntu ubuntu 2070 2012-01-01 19:23 gtnameserv
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/include
total 80
-rw-r--r-- 1 ubuntu ubuntu  3516 2012-01-01 19:23 jawt.h
-rw-r--r-- 1 ubuntu ubuntu  2349 2012-01-01 19:23 jawt_md.h
-rw-r--r-- 1 ubuntu ubuntu 66655 2012-01-01 19:23 jni.h
-rw-r--r-- 1 ubuntu ubuntu  1547 2012-01-01 19:23 jni_md.h
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/lib
total 12
drwxr-xr-x 2 ubuntu ubuntu 4096 2012-01-01 19:23 classpath
-rw-r--r-- 1 ubuntu ubuntu 1437 2012-01-01 19:23 logging.properties
drwxr-xr-x 2 ubuntu ubuntu 4096 2012-01-01 19:23 security
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/lib/classpath 
total 1228
-rwxr-xr-x 1 ubuntu ubuntu    806 2012-01-01 19:23 libjavaio.la
lrwxrwxrwx 1 ubuntu ubuntu     18 2012-01-01 19:23 libjavaio.so -> libjavaio.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     18 2012-01-01 19:23 libjavaio.so.0 -> libjavaio.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu 177244 2012-01-01 19:23 libjavaio.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu    818 2012-01-01 19:23 libjavalang.la
-rwxr-xr-x 1 ubuntu ubuntu    878 2012-01-01 19:23 libjavalangmanagement.la
lrwxrwxrwx 1 ubuntu ubuntu     30 2012-01-01 19:23 libjavalangmanagement.so -> libjavalangmanagement.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     30 2012-01-01 19:23 libjavalangmanagement.so.0 -> libjavalangmanagement.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu  25052 2012-01-01 19:23 libjavalangmanagement.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu    860 2012-01-01 19:23 libjavalangreflect.la
lrwxrwxrwx 1 ubuntu ubuntu     27 2012-01-01 19:23 libjavalangreflect.so -> libjavalangreflect.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     27 2012-01-01 19:23 libjavalangreflect.so.0 -> libjavalangreflect.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu  24773 2012-01-01 19:23 libjavalangreflect.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     20 2012-01-01 19:23 libjavalang.so -> libjavalang.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     20 2012-01-01 19:23 libjavalang.so.0 -> libjavalang.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu 378668 2012-01-01 19:23 libjavalang.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu    812 2012-01-01 19:23 libjavanet.la
lrwxrwxrwx 1 ubuntu ubuntu     19 2012-01-01 19:23 libjavanet.so -> libjavanet.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     19 2012-01-01 19:23 libjavanet.so.0 -> libjavanet.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu 263348 2012-01-01 19:23 libjavanet.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu    812 2012-01-01 19:23 libjavanio.la
lrwxrwxrwx 1 ubuntu ubuntu     19 2012-01-01 19:23 libjavanio.so -> libjavanio.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     19 2012-01-01 19:23 libjavanio.so.0 -> libjavanio.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu 311502 2012-01-01 19:23 libjavanio.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu    818 2012-01-01 19:23 libjavautil.la
lrwxrwxrwx 1 ubuntu ubuntu     20 2012-01-01 19:23 libjavautil.so -> libjavautil.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     20 2012-01-01 19:23 libjavautil.so.0 -> libjavautil.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu  27292 2012-01-01 19:23 libjavautil.so.0.0.0

If you compile Gnu Classpath with --enable-alsa and --enable-xmlj, you have 6 more libraries in /usr/local/lib/classpath folder :

-rwxr-xr-x 1 ubuntu ubuntu    877 2012-01-08 00:53 libgjsmalsa.la
-rwxr-xr-x 1 ubuntu ubuntu  67246 2012-01-08 00:53 libgjsmalsa.so
-rwxr-xr-x 1 ubuntu ubuntu    876 2012-01-08 00:53 libxmlj.la
lrwxrwxrwx 1 ubuntu ubuntu     16 2012-01-08 00:53 libxmlj.so -> libxmlj.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     16 2012-01-08 00:53 libxmlj.so.0 -> libxmlj.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu 381252 2012-01-08 00:53 libxmlj.so.0.0.0
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/lib/security 
total 4
-rw-r--r-- 1 ubuntu ubuntu 2489 2012-01-01 19:23 classpath.security
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/share
total 12
drwxr-xr-x 2 ubuntu ubuntu 4096 2012-01-01 19:23 classpath
drwxr-xr-x 2 ubuntu ubuntu 4096 2012-01-01 19:22 info
drwxr-xr-x 3 ubuntu ubuntu 4096 2012-01-01 19:22 man
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/share/classpath
total 10780
-rw-r--r-- 1 ubuntu ubuntu 9832050 2012-01-01 19:22 glibj.zip
-rw-r--r-- 1 ubuntu ubuntu 1204211 2012-01-01 19:23 tools.zip

If you compile Gnu Classpath with --with-escher and --enable-collections, you have 2 more files in /usr/local/share/classpath folder :

-rw-r--r-- 1 ubuntu ubuntu   382375 2012-01-08 00:53 collections.jar
-rw-r--r-- 1 ubuntu ubuntu   515042 2012-01-07 16:07 escher-0.3.jar
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/share/info     
total 292
-rw-r--r-- 1 ubuntu ubuntu  83532 2012-01-01 19:22 cp-hacking.info
-rw-r--r-- 1 ubuntu ubuntu 106990 2012-01-01 19:22 cp-tools.info
-rw-r--r-- 1 ubuntu ubuntu  98304 2012-01-01 19:22 cp-vmintegration.info
-rw-r--r-- 1 ubuntu ubuntu    815 2012-01-01 19:22 dir
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/share/man 
total 4
drwxr-xr-x 2 ubuntu ubuntu 4096 2012-01-01 19:23 man1
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox classpath-0.98 $ ls -l /usr/local/share/man/man1
total 164
-rw-r--r-- 1 ubuntu ubuntu  7997 2012-01-01 19:22 gappletviewer.1
-rw-r--r-- 1 ubuntu ubuntu  5592 2012-01-01 19:23 gcjh.1
-rw-r--r-- 1 ubuntu ubuntu  5918 2012-01-01 19:23 gjar.1
-rw-r--r-- 1 ubuntu ubuntu  9590 2012-01-01 19:23 gjarsigner.1
-rw-r--r-- 1 ubuntu ubuntu  5750 2012-01-01 19:23 gjavah.1
-rw-r--r-- 1 ubuntu ubuntu 35310 2012-01-01 19:23 gjdoc.1
-rw-r--r-- 1 ubuntu ubuntu 35536 2012-01-01 19:23 gkeytool.1
-rw-r--r-- 1 ubuntu ubuntu  4594 2012-01-01 19:23 gnative2ascii.1
-rw-r--r-- 1 ubuntu ubuntu  4825 2012-01-01 19:23 gorbd.1
-rw-r--r-- 1 ubuntu ubuntu  5084 2012-01-01 19:23 grmid.1
-rw-r--r-- 1 ubuntu ubuntu  5036 2012-01-01 19:23 grmiregistry.1
-rw-r--r-- 1 ubuntu ubuntu  4512 2012-01-01 19:23 gserialver.1
-rw-r--r-- 1 ubuntu ubuntu  4592 2012-01-01 19:23 gtnameserv.1

JamVM

[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jamvm-1.5.4 $ ls -l /usr/local/bin
total 444
-rwxr-xr-x 1 ubuntu ubuntu 400821 2012-01-01 19:38 jamvm
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jamvm-1.5.4 $ ls -l /usr/local/include
total 108
-rw-r--r-- 1 ubuntu ubuntu 14042 2012-01-01 19:38 jni.h

Note : JamVM replace the jni.h file from Gnu Classpath by his own jni.h file

[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jamvm-1.5.4 $ ls -l /usr/local/lib    
total 636
-rwxr-xr-x 1 ubuntu ubuntu    817 2012-01-01 19:37 libjvm.la
lrwxrwxrwx 1 ubuntu ubuntu     15 2012-01-01 19:37 libjvm.so -> libjvm.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     15 2012-01-01 19:37 libjvm.so.0 -> libjvm.so.0.0.0
-rwxr-xr-x 1 ubuntu ubuntu 556829 2012-01-01 19:37 libjvm.so.0.0.0
lrwxrwxrwx 1 ubuntu ubuntu     46 2012-01-01 19:38 rt.jar -> /usr/local/share/classpath/glibj.zip
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jamvm-1.5.4 $ ls -l /usr/local/share
total 16
drwxr-xr-x 2 ubuntu ubuntu 4096 2012-01-01 19:38 jamvm
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jamvm-1.5.4 $ ls -l /usr/local/share/jamvm   
total 24 
-rw-r--r-- 1 ubuntu ubuntu 22133 2009-12-31 19:42 classes.zip

Jikes

[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jikes-1.22 $ ls -ltr /usr/local/bin
total 8260
-rwxr-xr-x 1 ubuntu ubuntu 8002423 2012-01-01 19:56 jikes
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jikes-1.22 $ ls -ltr /usr/local/include
total 116
-rw-r--r-- 1 ubuntu ubuntu  5794 2012-01-01 19:56 jikesapi.h
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jikes-1.22 $ ls -ltr /usr/local/share
total 20
drwxr-xr-x 3 ubuntu ubuntu 4096 2012-01-01 19:56 doc
[SB2 mapping-armv7 armv7] ubuntu@ubuntu-VirtualBox jikes-1.22 $ ls -ltr /usr/local/share/doc/jikes-1.22
total 12
-rw-r--r-- 1 ubuntu ubuntu 11886 2012-01-01 19:56 license.htm

Links used to do the webOS port

Iphone

Patches used for the JamVM port for Iphone http://test.saurik.com/iphone/jamvm/

IPhone Java http://web.archive.org/web/20071230000038/http://iphone.fiveforty.net/wiki/index.php/IPhone_Java

Talk:IPhone Java http://web.archive.org/web/20071230050607/http://iphone.fiveforty.net/wiki/index.php/Talk:IPhone_Java

(JamVM Forum) JamVM port to iPhone? http://sourceforge.net/projects/jamvm/forums/forum/256481/topic/1866438

Tutorials Java on Iphone : http://iphoneroot.com/category/java/ http://iphoneroot.com/tutorial-install-java-on-the-iphone/

JamVM

JamVM developer blog http://draenog.blogspot.com/

how to build GNU Classpath and JamVM http://sourceforge.net/projects/jamvm/forums/forum/256481/topic/3208847?message=7193290 http://free-electrons.com/doc/java-labs.odt http://wiki.chumby.com/index.php/Java http://fuseyism.com/openjdk/cvmi/jamvmport.xhtml

JamVM used in Ubuntu https://launchpad.net/ubuntu/oneiric/+source/openjdk-6/6b23~pre4-0ubuntu1 with the latest code in GIT ??? http://draenog.blogspot.com/2011/02/openjdkjamvm-git-repository.html

OpenJDK

For the future when the next JamVM release will be available, replace Gnu Classpath by OpenJDK Java classes :

CrossCompilingOpenJDK https://evolvis.org/plugins/mediawiki/wiki/jalimo/index.php/CrossCompilingOpenJDK

CrossCompileFaq http://icedtea.classpath.org/wiki/CrossCompileFaq

JDK6 for embedded ARM http://mail.openjdk.java.net/pipermail/jdk6-dev/2009-April/000455.html

Simple Swing Tests with OpenJDK/Classpath/Classpath+Escher http://old.nabble.com/Simple-Swing-Tests-with-OpenJDK-Classpath-Classpath%2BEscher-td28605374.html