我可以通过cmd运行.jar文件,但我无法双击它们 [英] I can run .jar files through cmd, but I cannot double click them
问题描述
首先,我正在学习Java,但我仍然很新,所以复杂的代码将会超出我的想象。
First, I am studying Java, but I am still very new to it, so complicated code will go over my head.
当我下载.jar文件时说安装一个mod到我的世界并双击它,它不会运行。装载轮持续两秒钟然后停止,没有其他任何事情发生。我知道的.jar设置正确,因为它使用命令运行cmd
When I download a .jar file to say install a mod to minecraft and double click it, it doesn't run. The loading wheel goes for like two seconds and then stops, and nothing else happens. The .jar I know is set up right because it runs through cmd with the command
cd "wherever the file is"
java -jar "file name".jar
所以我已经尝试用它来运行它默认程序设置为java \jdk1.7.0_25 \ jre \ bin中的javaw.exe。没有任何反应。因此文件关联设置在正确的位置。我在这里不知所措。
So I've already tried to run it with the default program set as javaw.exe in the java\jdk1.7.0_25\jre\bin. Same where nothing happens. So the file association is set to the right place. I am at a loss here.
因为我仍然可以通过cmd运行它们,所以它并没有那么糟糕,但是当我到书中关于罐子的部分时,我希望能够通过Windows资源管理器GUI运行它,这就像使用我可以看到的.jar文件的一半好处。
It isn't so bad since I can still run them through cmd, but when I get to the part in the book about jars, I want to be able to run it through the Windows Explorer GUI, which is like half the benefit of using .jar files that I can see.
是否可能是注册表错误?我已经看到了很多关于这个问题的问题,但是大多数问题似乎都是设置.jar的问题,我没有这样做,而且我认为不是这样的。
Is it possibly a registry error? I have seen a lot of questions specifically about this problem, but most of them it seems were problems with setting up the .jar, which I didn't do, and I don't think that is the case here.
我有Windows Vista 64位。
I have Windows Vista 64bit.
如果我不够具体,请随时询问。
If I wasn't specific enough, feel free to ask.
推荐答案
我遇到了同样的问题,结果是注册表中的.jar文件关联被破坏了。以下步骤修复了它:
I had the same problem, and it turns out that the .jar file association in the registry was broken. The following steps fixed it:
打开注册表编辑器,然后导航到HKEY_CLASSES_ROOT\jarfile\shell\open \命令。修改Default键的值,如下所示:
[JRE的位置] \bin\javaw.exe-jar%1%*
替换[你的位置] JRE]与JRE安装的根目录。
例如:
C:\Program Files\Java\jre7\bin\javaw.exe-jar%1%*
对HKEY_LOCAL_MACHINE \ SOFTWARE \Classes \ jarfile \ shell \ openn \命令重复上述步骤。
Open the Registry Editor, and navigate to HKEY_CLASSES_ROOT\jarfile\shell\open\command. Modify the value of the Default key as follows:
"[Location of your JRE]\bin\javaw.exe" -jar "%1" %*
Replace [Location of your JRE] with the root directory of your JRE installation.
For example:
"C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
Repeat the above steps for HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open\command.
我有一台Windows 7机器,但我认为这也适用于32位环境。
I have a Windows 7 machine, but I assume this would work for 32-bit environments as well.
编辑:修复了示例中的路径 - 它应该使用Program Files目录而不是程序文件(x86)。
Fixed the path in the example - it should use the "Program Files" directory and not "Program Files (x86)".
这篇关于我可以通过cmd运行.jar文件,但我无法双击它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!