First we need a .jar file program.
Next we create a new file with the extension .manifest whose name is identical to the program's name. Right-click the .manifest and open it using an editor like Notepad++. Paste the following code into it:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<requestedExecutionLevel level="highestAvailable" uiAccess="False" />
The importance here is the 6th line where it requests the highest level of rights for the application.
Save the file and close the editor. Your directory should now look like this:
All preparations have been completed so we can launch Launch4j.
On the basic tab we select the .jar file by clicking on the browse (folder button). For the output file we copy and paste the file path to the jar file but change the .jar extension to .exe instead. Then we also choose our created .manifest file as Wrapper Manifest.
Before we can build the program we have to specify the minimum JRE version. Switch to the JRE tab and type 1.0.0 into the "Min JRE version" field. All the other options are optional.
An icon image can be converted to .ico using this site.
Now you can click on the gear in the menu bar to bring up a save dialog for the configuration file. Save it in the same directory as your program. If you wish to edit your options later, the .xml file can be loaded again in Launch4j.
Once you confirmed to save the configuration file, the .exe file gets created in the same directory.
The following texts should appear in the Log field:
Successfully created ...\My program.exe
In our project folder there are now 4 files including the .exe which will always run as administrator. You can tell by the little shield in the bottom right corner.
The remaining 3 files are no longer needed and can be deleted. The .exe is a fully standalone program which does the same as the .jar but with full rights.