I can run .jar files through cmd, but I cannot double click them

后端 未结 6 887
星月不相逢
星月不相逢 2020-11-29 09:52

First, I am studying Java, but I am still very new to it, so complicated code will go over my head.

When I download a .jar file to say install a mod to minecraft and

相关标签:
6条回答
  • 2020-11-29 10:01

    You have to do RightClick on the jar file and select open with... then, Choose default program... (i think that's the correct translation for "Elegir programa predeterminado" in spanish). On the Open with dialog select Java(TM) Platform SE binary. If you don't see that option you should search for the javaw.exe in your java installation folder, and select it. Also you should check Use the selected program to open this kind of file

    Best regards.

    0 讨论(0)
  • 2020-11-29 10:02

    Right click the jar and open with winzip or winrar

    0 讨论(0)
  • 2020-11-29 10:08

    If you don't care too much about understanding the underlying problem, this might help:

    http://johann.loefflmann.net/en/software/jarfix/index.html

    --and a double-clickable .jar needs to have Main-Class correctly set in MANIFEST.MF

    0 讨论(0)
  • 2020-11-29 10:08

    According to Johann Loefflmann, the root cause for the problem above is, that a program has stolen the .jar association. And he is right! Just follow the link below and install a small file JARFIX and the association will be set back and you can double click any jar file and run it in windows. It works for me (I have the same problem and before these I tried all solutions mentioned in the forum and failed).

    https://johann.loefflmann.net/en/software/jarfix/index.html

    0 讨论(0)
  • 2020-11-29 10:12

    I had the same problem, and it turns out that the .jar file association in the registry was broken. The following steps fixed it:

    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.

    I have a Windows 7 machine, but I assume this would work for 32-bit environments as well.

    EDIT: Fixed the path in the example - it should use the "Program Files" directory and not "Program Files (x86)".

    0 讨论(0)
  • 2020-11-29 10:14

    Just to reiterate - Meghan's answer fixed my problem of not being able to double-click to start a jar in Windows 7.

    • Open Registry editor

    • Navigate to HKEY_CLASSES_ROOT->jarfile->shell->open->command

    • Modify (Default) to "[Path to working JRE]/bin/javaw.exe" -jar "%1" %*

    • Make sure .jar files are opened by [Path to working JRE]/bin/javaw.exe by default

    0 讨论(0)
提交回复
热议问题