Confused about jar/lib usage
Andrew Haley
aph@redhat.com
Wed Feb 4 12:26:00 GMT 2004
Michael Koch writes:
> On Tue, Feb 03, 2004 at 01:26:10PM -0800, Fx Mx wrote:
> > I'm not actually interested in compiling libgcj.jar,
> > I'm interested in compiling another jar file. But
> > thought that libgcj.jar should work if any... so that
> > I could use this example to make sure I understood how
> > it worked.
libgcj is linked with a bunch of native code as well, so what you're
trying won't work. It's a special case.
> I compiled today gnujaxp.jar and used it in another app like this:
>
> gcj -c gnujaxp.jar (this produces gnujaxp.o)
> gcj -c Test.java (this produces Test.o)
> gcj -o test --main=Test Test.o gnujaxp.o
>
> Producing *.so directly is IMO not possible *.so files are several *.o
> files bundled together with ar.
I see we need an example. This is an example from GNU/Linux.
foo.java:
public class foo
{
static void hello ()
{
System.out.println("Hello, world!");
}
}
hello.java:
public class hello
{
public static void main (String[] argv)
{
foo f = new foo();
f.hello ();
}
}
And these are the commands:
$ gcj -shared foo.java -o libfoo.so -fpic
$ gcj hello.java --main=hello --classpath=. -lfoo -L. -o hello
$ LD_LIBRARY_PATH=. ./hello
Hello, world!
Andrew.
More information about the Java
mailing list