Every Java application requires JRE/JVM to run but not every user may have the virtual machine installed on her/his machine. One cannot expect every user to be smart enough to download and install JRE by reading instructions. There are a couple of approaches that a Java developer could take to make sure that her/his application works even if the JRE is not installed on the user’s system.
These approaches are enumerated as below.
1. Use any Open source intaller generator in java, which can run without JVM like launch4j. Installer will take the jar file and generate the .exe file and then bundle JRE with the application.
2. Run jar through a batch file-
a. Create a new folder and place the jre folder and the executable jar file within it.
b. Next, create a batch file in the same folder.
c. Finally, add the following code to the batch file and save it.
jre\bin\java.exe -jar installer.jar
Now the jar file can be executed through the batch file and the .exe file.