If I have a Java source file (*.java) or a class file (*.class), how can I convert it to a .exe file?
I also need an installer for my program.
If I have a Java source file (*.java) or a class file (*.class), how can I convert it to a .exe file?
I also need an installer for my program.
The latest Java Web Start has been enhanced to allow good offline operation as well as allowing "local installation". It is worth looking into.
EDIT 2018: Java Web Start is no longer bundled with the newest JDK's. Oracle is pushing towards a "deploy your app locally with an enclosed JRE" model instead.
GCJ: The GNU Compiler for Java can compile Java source code into native machine code, including Windows executables.
Although not everything in Java is supported under GCJ, especially the GUI components (see What Java API's are supported? How complete is the support? question from the FAQ). I haven't used GCJ much, but from the limited testing I've done with console applications, it seems fine.
One downside of using GCJ to create an standalone executable is that the size of the resulting EXE can be quite large. One time I compiled a trivial console application in GCJ and the result was an executable about 1 MB. (There may be ways around this that I am not aware of. Another option would be executable compression programs.)
In terms of open-source installers, the Nullsoft Scriptable Install System is a scriptable installer. If you're curious, there are user contributed examples on how to detect the presence of a JRE and install it automatically if the required JRE is not installed. (Just to let you know, I haven't used NSIS before.)
For more information on using NSIS for installing Java applications, please take a look at my response for the question "What's the best way to distribute Java applications?"
You can use Janel. This last works as an application launcher or service launcher (available from 4.x).
If you need to convert your entire application to native code, i.e. an EXE plus DLLs, there is ExcelsiorJET. I found it works well and provided an alternative to bundling a JRE.
Alternatively, you can use some java-to-c translator (e.g., JCGO) and compile the generated C files to a native binary (.exe) file for the target platform.
Launch4j