3

I would like to know which Java native compilers can be recommended to compile Java code to Windows and Mac OS X binaries.

Maybe someone knows which compilers have been used to create the Eclipse binaries. Those shouldn't be a wrong choice.

  • 3
    The eclipse binaries aren't native-compiled Java; they're native programs that use the JNI to launch a normal Java program. – Ernest Friedman-Hill Jul 19 '11 at 11:53
  • 1
    What goal are you hoping to achieve by such pre-compilation? – NPE Jul 19 '11 at 11:55
  • 1
    The JVM can compile byte code to native code on the fly for you. There are some tricks to force it to compile. What problem are you trying to solve? – Peter Lawrey Jul 19 '11 at 12:07
  • Beside the reason mentioned below, I also thought that it could be advantageous to be intependent of the installed JRE. – good_ingredient Jul 19 '11 at 12:13
  • You may install a private JRE alongside your app. There are tools that would package them together or download the JRE on demand. Unless you _also_ need code protection and/or the other potential benefits of going native (faster startup, smaller memory/disk footprint, better performance - any of which may or may _not_ apply to your specific app), native compilation is an overkill. – Dmitry Leskov Jul 20 '11 at 15:26
  • do you know about [the IKVM](http://www.mono-project.com/docs/about-mono/languages/java/#compiling-java-code-to-x86-code)? And RoboVM? – Janus Troelsen Feb 14 '15 at 15:31

2 Answers2

1

See here... But in short, there is no good solution that I would really recommend.

P Varga
  • 19,174
  • 12
  • 70
  • 108
  • As far as I know performance of natively compiled Java is not better than Java that runs in the VM, but natively compiled Java starts a bit faster. However, the main reason would be usability in form of expectance conformity, because most people are looking for an exe or app with an icon to start an application, but maybe it's better to use a binary only to start the application and then let the programme run in the VM. – good_ingredient Jul 19 '11 at 12:09
  • 1
    The main reason is that Java decompilers cannot deal with natively compiled Java. For usability, a dozen solutions exist that would bundle or download the JRE and install it in your app's directory. – Dmitry Leskov Jul 19 '11 at 12:15
  • Aha, the only reason to use a Java native compiler would be code protection? – good_ingredient Jul 19 '11 at 12:21
  • I have experience with Excelsior's JET compiler, which at the moment seems to be the only viable option when it comes to native compiling complex applications. Pros: Makes it hard to decompile your code, slightly better startup time. Cons: Cost (for commercial applications), your build process will become a lot more complex. – ddso Jul 19 '11 at 12:28
  • Thank you. This was a very tangible and practical answer. – good_ingredient Jul 19 '11 at 12:37
  • @Varga: Could you add a bit more information (maybe from the comments) to your answer? As it is, it is a bit sparse. – Paŭlo Ebermann Jul 19 '11 at 13:29
  • @dosendoc: I'd be grateful if you could elaborate on the complexity Excelsior JET adds to the build process. We invested a lot into the ease-of-use in recent years, so perhaps it was some old version you worked with? – Dmitry Leskov Jul 20 '11 at 15:29
  • We are working with the most recent version. We use a Maven repository for dependency management and build using Gradle on a CI server. We use Freemarker templates into which the dependency paths from the local Gradle cache are injected to build the Excelsior project files on-the-fly. A build script for a complete JET build is significantly more complex than one which simply performs a Maven-convention build and adds a JRE + launcher to the distribution package. There's simply more manual calling of processes and copying of files to do. Running the build will also take quite a while longer. – ddso Jul 21 '11 at 09:53
0

Eclipse uses as User Interface SWT, which uses the native plattform user Interface:

On Windows it looks like Windows, on Mac like Mac, etc. Its available for the most popular Plattforms, search for SWT for more info.

So that is probably what you saw, or more are feeling when you work with eclipse.
Its not only the exe extension.

AlexWien
  • 28,470
  • 6
  • 53
  • 83