Static executables

Scott Gilbertson scottg@mantatest.com
Tue Jan 31 17:59:00 GMT 2006


> Hi Per,
>> >> (i.e. private static final Class c1 = gnu.java.locale.Calendar.class)
> >
> >An optimizer might might remove an unused private field
> >that is initialized by a side-effect-free expression.
>> I didn't think about optimization. Thanks for clarifying this.
>> -- Mohan

I use the Class z = zzzzzz.class approach, and compile my application from
class files, and it works. The trick is to make a source file for the
purpose, and compile that specific file from the source file. That's also
where I put gcj-specific natives, so that I can run the jar file on a
non-gcj system (Windows PC / Sun JRE). The manifest in the jar file points
to a different main class, which is called from Main.main().
Example:
 gcj -O2 -c -o app.o app.jar
 gcj -O2 -c -o Main.o Main.java --classpath=.
 g++ -c natMain.cc
 gcj --main=Main -g -save-temps -o app.bin Main.o natMain.o app.o ...
It's also probably worth noting that you can strip the resulting binary to
reduce its size:
 strip app.bin


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /