In Java we can compile soure code into two types of executables: a .jar file, which is basically bytecode, and a .exe file, which is basically machine code. Under what circumstances would it be better to compile to an .exe versus a .jar, and vice-versa? Which one is faster to run? Thanks.
The only reason to create a .exe file is to make it easier to run an application or installer in Windows.
Java compiles to byte code which is then run in the JVM. Normally the .exe is just a wrapper that makes sure that the java VM is started and that the class bytes stored within the .exe (or any other location) are run.
Not exactly. There are tools that can create .exe files out of Java executable jars, but that's in no way a normal feature of the JDK.
There are very few cases where an .exe file would be an actual necessity, since to run a regular jar you just need to have Java installed and properly configured.
A simple test to decide whether to go for a jar or an exe is to ask yourself "Do you need this to be an .exe file?". If you can't answer that in under 5 seconds, go with a jar file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With