Compiling .java file to shared library

Andi Vajda andi@osafoundation.org
Tue Sep 26 16:14:00 GMT 2006


On Tue, 26 Sep 2006, Mike Purdy wrote:

> So, now I've successfully applied the dawrin x86 patches to a 4.0.2 tarball 
> and have successfully built it.
>
> Now, I would like to take a .java file and compile it into a native shared 
> library so that I could link and use it in a c++ application.  gcj -c -g -O 
> MyLibrary.java successfully creates an .o file.  What is the next step to 
> making a shared library?

To use it from C++, you have to generate a C++ header file for your class 
using gcjh and use that to compile calls into it.

I do something very similar when building PyLucene (a shared library serving 
as a python extension integrating Java Lucene). Take a look at its Makefile 
for examples:
      http://svn.osafoundation.org/pylucene/trunk/Makefile

Andi..



More information about the Java mailing list