How can I convert my Java program to an .exe file?
javapackager
The Java Packager tool compiles, packages, and prepares Java and JavaFX applications for distribution. The javapackager command is the command-line version.
– Oracle's documentation
The javapackager
utility ships with the JDK. It can generate .exe files with the -native exe
flag, among many other things.
WinRun4J
WinRun4j is a java launcher for windows. It is an alternative to javaw.exe and provides the following benefits:
- Uses an INI file for specifying classpath, main class, vm args, program args.
- Custom executable name that appears in task manager.
- Additional JVM args for more flexible memory use.
- Built-in icon replacer for custom icon.
- [more bullet points follow]
– WinRun4J's webpage
WinRun4J is an open source utility. It has many features.
packr
Packages your JAR, assets and a JVM for distribution on Windows, Linux and Mac OS X, adding a native executable file to make it appear like a native app. Packr is most suitable for GUI applications.
– packr README
packr is another open source tool.
JSmooth
JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself.
– JSmooth's website
JSmooth is open source and has features, but it is very old. The last release was in 2007.
JexePack
JexePack is a command line tool (great for automated scripting) that allows you to package your Java application (class files), optionally along with its resources (like GIF/JPG/TXT/etc), into a single compressed 32-bit Windows EXE, which runs using Sun's Java Runtime Environment. Both console and windowed applications are supported.
– JexePack's website
JexePack is trialware. Payment is required for production use, and exe files created with this tool will display "reminders" without payment. Also, the last release was in 2013.
InstallAnywhere
InstallAnywhere makes it easy for developers to create professional installation software for any platform. With InstallAnywhere, you’ll adapt to industry changes quickly, get to market faster and deliver an engaging customer experience. And know the vulnerability of your project’s OSS components before you ship.
– InstallAnywhere's website
InstallAnywhere is a commercial/enterprise package that generates installers for Java-based programs. It's probably capable of creating .exe files.
Executable JAR files
As an alternative to .exe files, you can create a JAR file that automatically runs when double-clicked, by adding an entry point to the JAR manifest.
For more information
An excellent source of information on this topic is Excelsior's article "Convert Java to EXE – Why, When, When Not and How".
See also the companion article "Best JAR to EXE Conversion Tools, Free and Commercial".
Compiling a java program into an executable
You can convert .jar file to .exe on these ways:
(source: viralpatel.net)
1- JSmooth .exe wrapper:
JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself. When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a web site.
JSmooth provides a variety of wrappers for your java application, each of them having their own behaviour: Choose your flavour!
Download: http://jsmooth.sourceforge.net/
2- JarToExe 1.8
Jar2Exe is a tool to convert jar files into exe files.
Following are the main features as describe in their website:
- Can generate “Console”, “Windows GUI”, “Windows Service” three types of exe files.
- Generated exe files can add program icons and version information.
- Generated exe files can encrypt and protect java programs, no temporary files will be generated when program runs.
- Generated exe files provide system tray icon support.
- Generated exe files provide record system event log support.
- Generated windows service exe files are able to install/uninstall itself, and support service pause/continue.
- New release of x64 version, can create 64 bits executives. (May 18, 2008)
- Both wizard mode and command line mode supported. (May 18, 2008)
Download: http://www.brothersoft.com/jartoexe-75019.html
3- Executor
Package your Java application as a jar, and Executor will turn the jar into a Windows exe file, indistinguishable from a native application. Simply double-clicking the exe file will invoke the Java Runtime Environment and launch your application.
Download: http://mpowers.net/executor/
EDIT: The above link is broken, but here is the page (with working download) from the Internet Archive. http://web.archive.org/web/20090316092154/http://mpowers.net/executor/
4- Advanced Installer
Advanced Installer lets you create Windows MSI installs in minutes. This also has Windows Vista support and also helps to create MSI packages in other languages.
Download: http://www.advancedinstaller.com/
Let me know other tools that you have used to convert JAR to EXE.
How Can I convert Java To Exe
The beauty of java is that it is platform independent. So, converting it to a platform-dependent executable is a great sin: it kills the very purpose of java!
But if you're okay with that, use some thirdparty software.
Commercial:
- JEXECreator
- exe4J
- NativeJ
- execJava
- Executor
- JExePack
- Jlaunch
Free:
- JSmooth
- Launch4j
- jstart32
- exeJ
- Janel
- jstart
- Roxes Ant Tasks
- Marner Java Launcher
- jelude
More similar discussions are here, here, here, here and even here.
How to convert a java fxml file into exe for windows with/with out jre
To make an .exe installer for a Java application, use the jpackage tool that comes with recent JDKs.
See https://docs.oracle.com/en/java/javase/14/docs/specs/man/jpackage.html
It will also bundle the JRE so everything is self-contained. This is actually the preferred way to distribute Java applications. jpackage can use the jlink tool to make a stripped down JRE, or you can provide a JRE image that you have already created (with jlink).
Related Topics
How to Send Http Request in Java
How to Use an Existing Database With an Android Application
Update Eclipse With Android Development Tools V. 23
Android: How to Use Alarmmanager
How to Efficiently Parse HTML With Java
Singletons Vs. Application Context in Android
Noclassdeffounderror - Eclipse and Android
Get Nested Json Object With Gson Using Retrofit
How to Set Java_Home in Linux For All Users
Rjava Load Error in Rstudio/R After "Upgrading" to Osx Yosemite
Connect Java to a MySQL Database
How to Convert My Java Program to an .Exe File
Solving a "Communications Link Failure" With Jdbc and MySQL
What Causes and What Are the Differences Between Noclassdeffounderror and Classnotfoundexception
How Does Java Handle Integer Underflows and Overflows and How Would You Check For It