How to double-click the JAR file in Windows

Source: Internet
Author: User

Before reading this article, make sure that the jar package has at least one main method entry and a graphical interface.
And ensure that the main-class in the META-INF/manifest file has pointed to the main method entry previously implemented.

Recently, the hard disk broke down, so I re-installed the OS and found that the copied JDK or JRE (uninstalled version) cannot open the jar file for execution (JDK version 1.6_11 ),
Therefore, in the open mode, it points to javaw.ProgramThe error message "cannot find main class" is displayed. At the same time, Windows associates a jar file with the specified Java W program, and finds the file online, no one mentioned the solution to this problem, but it is clear that this problem was not caused by the problem mentioned in the beginning.
Therefore, the definition of the current jar type is deleted in the current user configuration in the registry. However, it still does not work after you try again.

So I re-installed JDK and found that the JAR file can be opened this time, and the program used to open this time is still javaw. Compare the definitions of file types in the registry. From the perspective of Folder Options> file type, we finally see the difference. The open operation definition in the advanced section is as follows:
"C:/program files/Java/jre6/bin/javaw.exe"-jar "% 1" % *
If we select javaw, the default open operation does not have the-jar parameter and must be manually added.
We know that the parameter for starting the jar package in Java is-jar, but remember that Java W can open the jar directly in the past, and I do not know when to add the-jar parameter.

Therefore, for a copy of the green JRE, you only need to modify the definition of the open operation to solve the above problem.

Solved the above problem and generated a new problem. The previously selected javaw program cannot be lost in the open mode, which is redundant and can be modified in the registry.
You can delete the Response Program under hkey_classes_root/applications. It turns out that every time you use a program to open a file of the type, Windows will
Related records are left in the registry.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.