Compiling native resources

Jeff Sturm jsturm@sigma6.com
Tue May 2 10:21:00 GMT 2000


Many of our current Java projects use getResource() and
getResourceAsStream() to load arbitrary resources (usually property
files or scripts).

Since resources are in the classpath, they can be conveniently packaged
in a .jar file so I can distribute the entire application as a single
file.

When compiling to native code with gcj, I can still load resources from
the classpath.  But they are separate from the executable.  What is the
feasability of including these resources in the executable, perhaps as
an ELF segment, so that:

- the native-compiled binary can be distributed standalone
- there is no classpath to configure at runtime
- no filesystem access is required to access resources

It seems like this would be a win for embedded applications as well.

I don't know enough about gas/ld yet to attempt it... though it seems to
me that win32 already does about the same thing, with its resource
compiler.  (There is a GNU windres utility for the win32 port of
binutils if that is any help.)

-- 
Jeff Sturm
jsturm@sigma6.com


More information about the Java mailing list