This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Static executables
- From: "Scott Gilbertson" <scottg at mantatest dot com>
- To: <gnustuff at thisiscool dot com>, "Per Bothner" <per at bothner dot com>
- Cc: <tromey at redhat dot com>, "David Daney" <ddaney at avtrex dot com>, "Andrzej Bialecki" <ab at getopt dot org>, <java at gcc dot gnu dot org>
- Date: Tue, 31 Jan 2006 11:46:04 -0500
- Subject: Re: Static executables
- References: <KIW54JIJHBGE874ZYW3X505WV9E0.43df0c54@d9300>
> 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