This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
How to convert a jar into so file and use it ?
- From: David Michel <dmichel76 at googlemail dot com>
- To: java at gcc dot gnu dot org
- Date: Wed, 10 Jun 2009 10:39:57 +0100
- Subject: How to convert a jar into so file and use it ?
Hello,
I have a very simple java test code that uses a public method called
'coucou' of a external jar called 'Hello.jar' which contains the
package 'hello' and the public class 'Hello'. Here is the test code
Tool.java:
import hello.Hello;
public class Tool
{
public static void main(String[] args)
{
System.out.println("main program running");
Hello.coucou();
}
}
which I would usually compile, with the following commands:
$ gcj -O0 -g0 -C Tool.java --classpath=./:extern/Hello.jar
$ gij -cp .:extern/Hello.jar Tool
Now if I want to compile Tool.java natively with gcj, what do I need to do ?
I can create the shared library from the jar like this:
$ gcj -O0 -g0 -shared -findirect-dispatch -fjni -fPIC
extern/Hello.jar -o extern/Hello.jar.so
I can then compile Tool.java into Tool.o with:
$ gcj -O0 -g0 --classpath=./:extern/Hello.jar -c Tool.java -o Tool.o
(altough this is using the jar and not the so ??)
But then, I'm stuck with creating the final executable, i.e. Tool.out
Any clues ?
Cheers
David