Address: http://blog.csdn.net/zhangkaihang/article/details/7684500
There are two types of jar files after Java packaging.
1. A single jar package, for example, the database vendor driver used in the project, you can use the class in the package to import the jar package using eclipse.
2. Java is packaged into executable GUI applications.
In Windows 7, you cannot double-click to open an executable GUI application packaged in Java.
Sometimes the open method of the JAR file is always associated with the compression software. At this time, we have to re-associate it with the JVM virtual machine.
Of course, we can use Java-jar *. jar in the command line to execute (* indicates the JAR file name)
I. Solution: in Windows 7, you cannot double-click to open the jar file.
Modify the registry key and set hkey_classes_root \ applications \ javaw.exe \ shell \ open \ command
Change the data value to "D: \ Program Files \ Java \ jdk1.6.0 _ 21 \ JRE \ bin \ javaw.exe"-jar "% 1"
(You only need to add-jar to the original value ). For example:
Note 1: Some people can right-click the open method of the JAR file and select the default program to locate javaw.exe in JRE \ bin, but it still cannot run, this is because the-jar parameter is missing in the Command executed during double-click. In Windows 7, you can only modify the registry. Windows XP does not have to be so troublesome. The solution in Windows XP is attached below.
NOTE 2: after the experiment, the JAR file name cannot be Chinese.
Ii. Solutions in Windows XP
Procedure:
1. Tools -- Folder Options -- file type
2. If there is no jar, create a new extension. If there is an extension, modify it.
3. Click create.
4. the "advanced" button appears in the "edit file type" window.
Click "New (n)..." to display the "New Operation" window. Name the operation "open ",
The application executing the operation is "D: \ Java \ jdk1.6.0 _ 12 \ JRE \ bin \ javaw.exe-jar % 1 ".
(Note: D: \ Java \ jdk1.6.0 _ 12 is the JDK Directory, which is set based on the actual environment on the PC .)