This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static executables


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]