Make your JAR a standalone executable with Launch4J (Step-by-step tutorial for newbies).
Hello! I was doing some researches about how can I convert my complex JAR program (12 MB) in a standalone executable that can be runned without JRE installed.
I am using Launch4J; in this repository I’ll show you how to use it.
Java installed (For developer machine);
Your JAR (Make sure it runs correctly in a machine with Java installed);
A .ico file as icon for your exe built file (You can download them for example for free from https://www.iconfinder.com or make/buy custom icons, or google .ico);
A JRE to bundle to your exe built file (Read below).
Java applications, as you know, can be executed thanks to a Java Virtual Machine (JVM), that can be a JRE (Java Runtime Environment) or a JDK (Java Development Kit).
Without a JVM, Java applications just cannot be executed and they look as raw archives to a normal user. In Windows systems for customers, Java is normally NOT installed, so customers would be very confused and annoyed to go to Java website and download JVM to run their jar file. This could cause potential loss of customers and downvote your product.
Launch4J allows you to bundle a JVM inside exe file, so:
Try to pick the lowest JRE possible that can run your project. Make a compromise between compatibility and security. Oracle fixes Java vulnerabilities by updating their JVMs, so it is always recommended to choose a good updated JRE.
You can download the latest JRE if you need best security possible and don’t need compatibility with older machines.
You can download older JRE if compatibility is a concern from you enough to withdraw security.
Choose .tar.gz archive for download.
In this project I’ll assume your Java project dir has this path for ease of understanding: C:\Users\Finalgalaxy\Documents\java_projects\proj1\
There are many other options to check them out.