Why doesn't GCJ find classes from my imported packages?

I want to compile a small Java application into a Windows executable.

The application is very small, only one main class, but uses Apache POI.

When I compile it, everything works fine, as long as I put the POI Jar in the class path argument.

But when it comes to references, GCJ cannot resolve class references in the POI package. All messages are as follows:

undefined reference tp 'org::apache::poi:hssf:usermodel:HSSFWorkbook::class$' 

What do I need to do to link my application?

+6
java linker gcj
source share
1 answer

You must compile the imported Jars into .so libraries separately. Be sure to specify Jars in --classpath , both when compiling libraries, and when compiling code.

Example when I compile the GNU cryptographic library:

 gcj --classpath=source/:libs/gnu-crypto.jar -fjni -c libs/gnu-crypto.jar -o libs/gnu-crypto.o gcj -shared -fPIC -o libs/libgnu-crypto.o libs/gnu-crypto.o -o libs/libgnu-crypto.so 

Finally, execute your executable through a shell script that references the library path. For example:

 #!/bin/sh export LD_LIBRARY_PATH=./libs/:$LD_LIBRARY_PATH exec ./MyJavaApp $* 
+5
source share

All Articles