Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

java - executing .jar file with an argument by mouse right-click on Windows?

I find the ChkBugReport to be very interesting: http://developer.sonymobile.com/knowledge-base/tools/analyse-your-bugreports-with-our-open-source-tool/

so I would like to use it on my Windows7 but in a simple way.

In order to use the tool that is in jar, I need to type the following in the command prompt:

java -jar ChkBugReport_ver.jar dumplog.txt

where the dumplog.txt is the log I want to analyze by the tool.

The thing is that it is quite tiresome to run cmd and then type "java -jar... blah blah.." everytime I want to use it so I would like to link it to the mouse right-click context menu in Windows Explorer.

i.e., browse through to the file I want to analyze in Windows Explorer, then right-clicking on it would provide a menu like "run ChkBugReport.." then it does the "java -jar ChkBugReport_ver.jar clicked-file.txt" and generates the output.

Is there a way to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Follow these steps:

  1. Open regedit (as administrator).

  2. Locate key HKEY_CLASSES_ROOT*shell. In case you want to add the context menu for a specific extension only, use e.g. HKEY_CLASSES_ROOT.xmlshell for xml. If the shell key doesn't exist, create it (right-click on the parent key and select New -> Key).

  3. Right-click on the shell key, and select New -> Key. Enter the name of the command displayed in the context menu, e.g. Check Bug Report.

  4. Right-click on the Check Bug Report key and select New -> Key. Enter text command (in lowercase).

  5. Click on the command key and then double-click on the (Default) key in the right pane to edit the string value. Enter the command to be executed. Placeholder for the argument is %1. For ChkBugReport_ver.jar, you can use

    java -jar "C:PathToChkBugReport_ver.jar" "%1"
    

See also this tutorial.

(Works with my Windows 7)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...