Compiling XML parsers (xerces, Dom4j, etc...)
Andrew Haley
aph@redhat.com
Thu Nov 4 10:39:00 GMT 2004
Bryce McKinlay writes:
>
> >First, gcj can in fact compile jar files into usable libraries (as we
> >all know or have read), but there are limitations which are not clearly
> >advertised or documented (at least not in any obvious way).
> >
> >1) The first limitation is that in order to get working libs from jars
> >you have to work with this assumption. The jar can only contain one
> >package.
No.
> Yes, unfortunately this is a well-known limitation of the existing
> shared-library naming scheme.
All you have to do is link explicitly against the shared library.
Given two packages:
package package1;
public class hello
{
public void foo()
{
System.out.println("Hello from " + getClass());
}
}
package package2;
public class hello
{
public void foo()
{
System.out.println("Hello from " + getClass());
}
}
And a main:
public class main
{
static public void main(String[] argv)
{
new package1.hello().foo();
new package2.hello().foo();
}
}
You do this:
$ gcj -shared -o libfoo.so package1/hello.java package2/hello.java
$ gcj -o hello main.java -lfoo -L. --main=main
$ LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./hello
Hello from class package1.hello
Hello from class package2.hello
Andrew.
More information about the Java
mailing list