Java 双击在 Vista 上执行 Jar

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/354664/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 13:44:40  来源:igfitidea点击:

Executing a Jar on Vista with a double click

javawindows-vistaexecutable-jar

提问by Leonard H. Martin

This pretty much has me defeated.

这几乎让我失败了。

On XP and earlier versions of Windows you could customise Open With filetypes to include java - jar "myjar.jar", but on Vista this functionality seems to have been removed. I can of course create a .bat file to launch my application, but is it possible to make Vista execute a .jar as required?

在 XP 和更早版本的 Windows 上,您可以自定义打开方式文件类型以包含 java - jar "myjar.jar",但在 Vista 上,此功能似乎已被删除。我当然可以创建一个 .bat 文件来启动我的应用程序,但是是否可以让 Vista 根据需要执行一个 .jar 文件?

采纳答案by RealHowTo

You can do it from the command line with 2 utilities.

您可以使用 2 个实用程序从命令行执行此操作。

The first one, ASSOC, is used to create a file association. To verify if there is one defined for JAR type :

第一个 ASSOC 用于创建文件关联。要验证是否为 JAR 类型定义了一个:

>assoc .jar
.jar=jarfile

If not found then create it with :

如果未找到,则使用以下命令创建它:

>assoc .jar=jarfile

The next step is to define the association. This is done with FTYPE.

下一步是定义关联。这是通过 FTYPE 完成的。

To verify if one is already defined , type

要验证是否已经定义了一个,请键入

>ftype jarfile
jarfile="C:\Program Files\Java\jre1.5.0_10\bin\javaw.exe" -jar "%1" %*

Again if not found or the wrong JRE is used, use FTYPE to fix the problem

再次如果未找到或使用了错误的 JRE,请使用 FTYPE 修复问题

>ftype jarfile="C:\Program Files\Java\jre1.5.0_10\bin\javaw.exe" -jar "%1" %*

回答by berlindev

Use the software JarFix >= 1.1.0 . There is Vista support included and it "recovers" the .jar association!

使用软件 JarFix >= 1.1.0 。包含 Vista 支持,它“恢复”了 .jar 关联!

download for example here: http://www.softpedia.com/get/Others/Miscellaneous/Jarfix.shtml

例如在这里下载:http: //www.softpedia.com/get/Others/Miscellaneous/Jarfix.shtml