Under Windows, it is impossible to directly launch a .jar file even if a JVM (Java Virtual Machine) is installed. This is due to Windows, which is and will remain stupid for a long time!
Explanation:
Windows does not know how to associate a .jar extension with a Java application.
To work around the problem, there are two methods.
The first will consist of teaching Windows how to launch the JVM from a double-click on a .jar file.
This method is reserved for someone with solid knowledge; I still offer it for general knowledge, knowing that the second method is simpler.
First method
You will have to tinker with the registry to associate jar
to disk:/path/java -jar %1
From Windows Explorer
Tools\Folder Options\File Types\New
jar; type = java:
Advanced
Action = Execute
Program = disk:/path jre/java -jar %1
From regedit, copy an existing key (iexplore for example)
and place the same information as above.
Save a .reg file containing this modification to re-implement it later in case of system reinstallation.
Second method:
Using Launch4j
Launch4j is software that allows you to create launchers for your Java applications. It will create an .exe to launch your .jar. This software is under GPL license, so it is completely free. It is available on Windows, Linux, MacOSX, and Solaris.
You can configure various options for the JVM and for the program creation. You can also add an icon to your programs.
Here is a (non-exhaustive) list of everything Launch4j allows you to do:
Launch4j Features
* Ability to use a dynamic ClassPath with environment variables
* Ability to put an icon on your launcher with different resolutions and colors
* Displays a native SplashScreen from a BMP image before launching the JVM
* The process name is the name of your executable, making it easy to find
* Works with a specified JVM or will fetch it
* Displays a Java download page if there is no JVM or if it is not appropriate
* Can create launchers for graphical or console applications
* Command line arguments can be passed to the launcher
* Modification of heap size values
* Can configure JVM options via the graphical interface
* Ability to use a .ini file for JVM options
* Ability to modify environment variables
* Can add information to the launcher such as author and version
* It can be used for commercial applications
* It can be used on the command line or with the graphical interface
* Compilation can be done via Ant
* The launcher works on all Windows platforms
As you can see, Launch4j allows for a lot of things, but despite that, it remains quite simple to use through its very user-friendly graphical interface.
Official Launch4j website
http://launch4j.sourceforge.net/ Source:
https://fr.answers.yahoo.com/question/index?qid=20091008141005AAzg9WX