Any JAVA programmer you have ever needed port your programs to native windows executables (especially those based on SWING, the JAVA GUI creation library) has run into the same problem.
By default, the execution of JAR files with a double mouse click requires that the user have the option of opening this type of program with the correct version of JAVA on their system (by default, some systems open it with winrar when it is installed with the basic options).
Many times the average user will not have knowledge of this or how to modify it, so the program can lose this type of user although its functionality is tremendously useful.
To avoid this contingency, Regex Laboratory has created a utility that seems essential: Jar2Exe
In RedesZone we are going to comment a little on this little tool, which is not free, but its cost is quite accessible: 11’13 euros for the standard version, with which we have plenty if we dedicate ourselves to free software and we are not interested in encrypting our code .
This program allows, starting from a .jar file, to create a Windows executable with multiple options that we will discuss in the article.
The first thing is to download the program from its official website:
We are going to download the free version, but we insist that the standard version, 11 euros, is more than enough for professional use.
We install and run it and the following screen appears:
This screen appears because our version is the free version. We simply click Next, the evaluation period is 30 days and it is more than enough for our article.
When you press next, this screen appears:
On this screen we choose our JAR file and the version minimal JAVA that our application needs.
We choose our test file and select JAVA version 1.6 as the minimum version:
We press next and we find this screen, in which we choose what type of application we are going to need. In our case it will be an application with a graphical interface, so we choose the second option:
And we click next. The program redirects us to this screen, in which we choose our Main class (the one that starts our JAVA program) and an image that will be used as Splash. In our case, our program already has a splash window, so we leave it blank. In most cases, the Main class will detect itself, if there is only one main in the application.
We choose and click next, navigating to this screen, in which we can configure different options: that the application is placed as an icon on the taskbar, that it supports the Windows log system and encrypt our JAVA file and its classes, to avoid where possible the hacking of our application. These are our options:
We press next and we see this screen, which only serves to add another .jar file and repeat the previous steps. In our case, it is not necessary.
We press next and on this screen we choose our icon for the program and its name when we create it. In our case, it will be Programa.exe and our icon will be a Windows icon, looking like this:
We click next and the .exe file is generated, next to our .jar file: it is ready to distribute and be used by our Windows users: