<p>Is it really viable to use GCJ to publish server-side applications?  Webapps?  </p>

<p>My boss is convinced that compiling our (<strong><em>my</em></strong>) webapp into a binary executable is a brilliant idea.  (Then again, he likes nice, small simple things with blinky lights that he can understand.)  He instinctively sees no issues with this, while I only see an endless series of problems and degradations.  Once I start talking to him about the complexity of our platform, and more in depth specifics of byte code, JVMs, libraries, differences between operating systems, processor architectures, etc...well...his eyes glaze over, he smiles and he has made it clear he thinks I'm being childishly resistive.</p>

<p>Why does he want a single magic executable?  He sees a couple of "benefits":</p>

<ul>
<li>If it is a binary executable, then it is hard to reverse engineer and circumvent any licensing.  Management lives in constant fear that this is happening, even though we sell into larger corporates who generally do not do cheat with server software.  </li>
<li>There is that vision of downloading this magic executable, running it, and everything works. (No more sending me out to do customer installations, which is not that frequent.)</li>
</ul>

<p>So, I've done my obligatory 20 minutes of googling, and now I am here.  </p>

<p>A bit of background on my application: </p>

<p><strong>What it is made from:</strong></p>

<ul>
<li>Java 6 (Sun's JVM)</li>
<li>AspectJ 1.6</li>
<li>Tomcat 6</li>
<li>Hibernate 3</li>
<li>Spring 2</li>
<li>another two dozen supporting jar files</li>
</ul>

<p><strong>What it does</strong></p>

<ul>
<li>A streaming media CMS</li>
<li>Performance sensitive</li>
<li>Deployed on Linux, Solaris, Windows (and developed on a Mac)</li>
</ul>

<p>As you can probably gather, I'm highly skeptical of this <em>"compiling Java to native code"</em> thing.  It sound like where Mono (VB on Linux) was back in 2000.  But am I being overly pessimistic?  Is it viable?  Should I actually spend the time (days if not weeks) to try this out?</p>

<p>There is one other similar thread (<a href="https://stackoverflow.com/questions/53845/java-compiler-options-to-produce-exe-files">Java Compiler Options to produce .exe files</a>) but it is a bit too simple, the links dated, and not really geared towards a server-side question.</p>

<p>Your informed opinions will be highly cherished, my dear SOpedians! TIA!</p>

[{'answer_id': 65065, 'author': 'Ryan P', 'author_id': 1539, 'author_profile': 'https://Stackoverflow.com/users/1539', 'pm_score': 3, 'selected': True, 'text': '<p>FWIW: I have never had good luck with GCJ, I have had a lot of problems using it and have had some obscure issues pop up that took forever to diagnose to GCJ rather than me (I am always very very reluctant to blame things on external libraries). I will openly admit this happened several years ago and I have never wanted to go near GCJ again. To give that more substance this was while I was in school and was working on a mostly trivial program so on an <em>"enterprise level"</em> I have had a healthy fear of GCJ.</p>\n'}, {'answer_id': 65069, 'author': 'ordnungswidrig', 'author_id': 9069, 'author_profile': 'https://Stackoverflow.com/users/9069', 'pm_score': -1, 'selected': False, 'text': '<p>I don\'t think that a large application like yours will compile to machine code. Remember that java is not only java syntax (might compile to machine code) but also a virtual machine which is more like an application / process environment. I would suggest making an <a href="http://classworlds.codehaus.org/uberjar.html" rel="nofollow noreferrer">uberjar</a> or like that instead.</p>\n'}, {'answer_id': 65109, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': "<p>I don't know about GCJ, but my company uses Excelsior JET with success.  We haven't done it with a webapp (yet) but it should be able to handle anything that the Sun JRE can.  In fact JET is a Sun-certified Java implementation.</p>\n"}, {'answer_id': 65733, 'author': 'James A. N. Stauffer', 'author_id': 6770, 'author_profile': 'https://Stackoverflow.com/users/6770', 'pm_score': 2, 'selected': False, 'text': "<p>Having one executable has a few downsides:</p>\n\n<ul>\n<li>You can't patch it as easy (i.e. replace one class file)\n<li>I don't think it can be called a webapp -- I assume it won't run in Tomcat.\n<li>It is non-standard so that increases your maintenance costs.\n<li>It is non-standard so tool support is reduced.\n</ul>\n\n<p>If he wants something simple maybe a war or ear would be better.  I can't see any benefit to doing this -- I would think this <em>might</em> be beneficial it it was a standalone application that you distributed so that people can just double-click on it.</p>\n"}, {'answer_id': 72914, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': -1, 'selected': False, 'text': '<p>Perhaps your boss just needs a demo as to how easy it is to distribute and deploy a war file for your customers on their own app servers.  Every file is "binary", so you might be too-literal in thinking he means an executable on the command-line.</p>\n'}, {'answer_id': 3734522, 'author': 'MAK', 'author_id': 125382, 'author_profile': 'https://Stackoverflow.com/users/125382', 'pm_score': 0, 'selected': False, 'text': "<p>I've only used GCJ very briefly, and quickly moved to Sun's JDK. The main problems I saw was that GCJ seems to always lag a little behind the latest version of Sun's JDK and that there were weird mysterious bugs caused by subtle differences with Sun's JDK. In version 1.5 (which is supposd to be compatible with Sun's v1.5), I had problems compiling using generics, and finally gave up and moved to Sun's JDK.</p>\n\n<p>I must say, any difference in performance was negligible (for my purposes, YMMV) and really the solution for installation issues is to create an installer for your app. Reverse engineering a binary isn't really all that harder than reverse engineering bytecode. Use an obfuscator if it is that important.</p>\n\n<p>Overall, I think the compatibility problems involved in using GCJ greatly outweighs any gains (which I think questionable at best) you might possible derive from it. Try compiling parts of your app in gcj and see how it goes though. If it works out fine, otherwise you get something solid to pitch to your boss.</p>\n"}, {'answer_id': 3734683, 'author': 'Jaydee', 'author_id': 417228, 'author_profile': 'https://Stackoverflow.com/users/417228', 'pm_score': 0, 'selected': False, 'text': "<p>I'll play devils advocate a bit, though I know little about GCJ. </p>\n\n<p>Compiling to native code may give your application a performance boost and use less memory, so if it can be made to work, there are advantages for the business in terms of competition.</p>\n\n<p>Being able to support an application better is also a good for business. </p>\n\n<p>So perhaps it is worth investigating baring in mind that nothing can lose a customer faster than an application that doesn't work.</p>\n\n<p>You need proper project time to try this out and a customer, that knows what they are getting into, that is willing to give it whirl (harder to find).</p>\n"}, {'answer_id': 3740493, 'author': 'user451234', 'author_id': 451234, 'author_profile': 'https://Stackoverflow.com/users/451234', 'pm_score': 2, 'selected': False, 'text': '<p>Excelsior JET is the definitive answer</p>\n'}]
['https://Stackoverflow.com/questions/65010', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2961/']