Who has successfully compiled a Java business project to native (e.g. using GCJ or Excelsior JET) and can share the pros and cons?
I image following advantages:
- more speed (the user’s machine does not need to compile byte code to native code)
- less possibility to hack
- no separate Java runtime required
and following disadvantages:
- needs a special build for each platform to support (but that’s required for SWT already)
- some features like reflection might not work?
- harder to locate bugs (what about stacktraces)?
I’ve used Excelsior JET to compile an SWT app to native for Windows.
This was some time ago, and they’ve improved the tool immensely since then, but JVM speed has since also improved commensurably. Memory usage not so much, but then even low end laptops have GB’s of RAM these days and, although it might disgust our sense of frugality, it really doesn’t matter if your small GUI app uses 20MB of memory on a box with at least 50x that amount, especially when you factor in the advantages of developing in this sort of environment.
The main reasons to static compile are startup time and memory usage. JET gave me these, but at the expense of a long build cycle, bugs in missing classes due to dynamic loading conflicting with static compilation (this is something I believe they’ve improved a lot) and platform-specific builds (you must build the Windows distro on Windows). Eventually Moore’s Law and JVM speeds made these trade-off’s not worth it, and I dropped this build option.
FWIW, stacktraces and reflection are fine, as is dynamic class loading if you make sure the compiler knows about the classes that are not statically referenced. If you’re worried about decompilation, well, an obfuscator will likely give you as much mileage.
I have nothing but good things to say about JET and the people that make it though. If you need to do it, JET’s a solid product.