Introduction
Quick instructions on getting started with GNU Classpath on Cygwin using either JamVM or SableVM. Note that these instructions intentionally exclude the GTK peers!
Contents
Requirements
Cygwin - http://www.cygwin.com
- For JamVM:
GNU Classpath 0.16 - http://www.classpath.org
JamVM 1.3.1 (with minor modification, see below) - http://jamvm.sf.net
- For SableVM
Jikes 1.22 http://jikes.sourceforge.net (download link on the left)
SableVM and SableVM-Classpath http://sablevm.org/download/snapshot/ (use latest snapshot)
Prerequisites
Cygwin installation
Follow normal cygwin installation procedure, making sure the following packages (and dependencies) get installed:
- gcc-core
- gcc-g++
- gcc-java
- make
- zip
For SableVM as above, plus:
- bzip2
- libtool
(it's much easier to find all these from Cygwin's 'All' package view than going through categories)
Jikes installation
Fairly self-explanatory, nothing special in this build.
$ tar -xjf jikes-1.22.tar.bz2 $ cd jikes-1.22 $ ./configure $ make && make install $ cd ..
GNU Classpath
Classpath installation (also SableVM-Classpath)
Depending on which GNU Classpath distribution (plain vs. sablevm) the installation is identical, save for the name of the tarball and the resulting directory.
$ tar -xzf classpath-0.16.tar.gz # or tar -xzf sablevm-classpath-trunk+4209.tar.gz $ cd classpath-0.16 # or cd sablevm-classpath-trunk+4209 $ ./configure --disable-gtk-peer $ make && make install $ cd ..
(note that although make install generates a lot of error, glibj.zip should have installed successfully)
JamVM
JamVM installation
Extract JamVM:
$ ln -s /lib/libcygwin.a /lib/libdl.a $ tar -xzf jamvm-1.3.1.tar.gz $ cd jamvm-1.3.1
(note the symlinking of libcygwin here, this is required because of the configure build spoof)
Edit src/dll.c (line numbers may vary) from:
298 char *getDllName(char *path, char *name) {
299 char *buff = sysMalloc(strlen(path) + strlen(name) + 8);
300
301 sprintf(buff, "%s/lib%s.so", path, name);
302 return buff;
303 }
To (change the sprintf call and allocate 3 more chars for *buff):
298 char *getDllName(char *path, char *name) {
299 char *buff = sysMalloc(strlen(path) + strlen(name) + 11);
300
301 sprintf(buff, "%s/cyg%s-0.dll", path, name);
302 return buff;
303 }
Configure and build JamVM:
$ ./configure --build=i686-linux $ make && make install $ cd ..
(note the use of spoofed build target to convince JamVM to build on cygwin)
Running a test program with JamVM
Type the following code snippet into Test.java:
public class Test {
public static void main(String[] args) {
System.err.println("Hello World!");
}
} Now compile and run the test:
$ gcj -C Test.java $ jamvm.exe Test
You should now see:
$ jamvm.exe Test Hello World!
SableVM
SableVM installation
GCC/GCJ come with an incomplete version of libffi apparently, so it's a good thing SableVM can substitute its own:
$ tar -xzf sablevm-trunk+4209.tar.gz $ cd sablevm-trunk+4209 $ ./configure --with-internal-libffi # will become the default for Cygwin soon $ make && make install $ cd ..
Running a test program with SableVM
Type the following code snippet into Test1.java:
public class Test1 {
public static void main(String[] args) {
System.err.println("Hello World One!");
}
} Now compile and run the test:
$ gcj -C Test1.java $ java-sablevm Test1
You should now see:
$ java-sablevm Test1 Hello World One!
Troubleshooting
I get the following error, what's up?
$ jamvm.exe Test Exception occurred while VM initialising. java/lang/NoClassDefFoundError: java/lang/Thread
This is JamVM's way of telling you it couldn't find glibj.zip from GNU Classpath. This usually occurs if you've forgotten to install 'zip' for cygwin. Install it and reconfigure && build classpath.
