Results 1 to 12 of 12
  1. #1
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Unhappy double-cliick fails to run program.jar

    On Windows 8 with a newly installed Java, double-clicking a program.jar file does not run the program. A cmd window flashes, but goes away before I can read it. There is no problem when I open a cmd window and type:
    Java Code:
    java -jar program.jar
    The manifest file has got a Main-Class declaration:
    Java Code:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.8.3
    Created-By: 1.7.0_11-b21 (Oracle Corporation)
    Class-Path: lib/Debug.jar lib/UI.jar lib/commons-lang3-3.1-sources.jar
      lib/commons-lang3-3.1.jar
    Built-By: Zweibieren
    Implementation-Vendor: physpics.com
    Implementation-Title: Indexer
    Implementation-Version: 3.7 (344zb Jan 22, 2013)
    Main-Class: com.physpics.indexer.Indexer
    Windows 8 is vastly "simplified" in file association setting. There seems to be nothing I can do.

    Have you any ideas that might help???

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    357
    Rep Power
    5

    Default Re: double-cliick fails to run program.jar

    When you right click the jar, and select 'open with', do you see a Java Runtime listed? If it is, you can make it the default to open .jar files, that should work.

  3. #3
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default Re: double-cliick fails to run program.jar

    Thanks, I'll try this next week when I get back to the project.

    Though I do wonder why a standalone JRE should differ from the JRE in the JDK that I have been using.

  4. #4
    jairoh_ is offline Member
    Join Date
    Feb 2012
    Posts
    23
    Rep Power
    0

    Default Re: double-cliick fails to run program.jar

    of the above suggestion doesn't work, try reinstalling java and it will automatically set default

  5. #5
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default Re: double-cliick fails to run program.jar

    Loading a jre does not help.

    After many clicks to generate the flashing window. I have been able to read the error message. When I double click on U:\Fred\java\test\dist\test.jar the error is
    Java Code:
    Error: Could not find or load main class U:\Fred\java\test\dist\test.jar
    This is exactly the same error I get when I give the command
    Java Code:
    java u:\Fred\java\test\dist\test.jar
    It is my belief that the new file association tool is broken. It does nothing more than pass the clicked file as an argument to the associated application. That means that the crucial " -jar " is omitted from the command, as above.

    The obvious answer is that java.exe should be smart enough to know the difference between a package name and a jar file.

    I have had no luck attaching a .bat file as a file association.

    Perhaps a C program can work.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,789
    Rep Power
    25

    Default Re: double-cliick fails to run program.jar

    Is there a command line somewhere that can be modified: insert the "-jar" option?
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Smile Re: double-cliick fails to run program.jar

    AHHA. The new file association scheme omits the " -jar " in trying to run the jar file.

    I wrote a trivial C program to bridge th gap:
    Java Code:
    #include <string.h>
    #include <stdlib.h>
    void main (int argc, char **args) {
        char *jarfile = args[1];
        int n = strlen(jarfile);
        char *cmd = (char *)malloc(n+50);
        strcpy(cmd, "java -jar \'");
        strcat(cmd, jarfile);
        strcat(cmd, "\'&");
        system(cmd);
    }
    Compiled with "cc -o runjar.exe runjar.c" if you happen to have cygwin installed. (Attaching does not seem possible at the moment.)

    To use this trick, set your file association for .jar to be runjar.exe. Then double-click on an executable jar file and it will run.

  8. #8
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default Re: double-cliick fails to run program.jar

    Quote Originally Posted by Norm View Post
    Is there a command line somewhere that can be modified: insert the "-jar" option?
    Sigh. The new file association scheme for Windows 8 does away with all sorts of things, including a command line.

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,789
    Rep Power
    25

    Default Re: double-cliick fails to run program.jar

    What about using the regedit program to fix the command line for .jar files?
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default Re: double-cliick fails to run program.jar

    Quote Originally Posted by Norm View Post
    What about using the regedit program to fix the command line for .jar files?
    If you don't understand my response, don't ignore it, ask a question.
    Okay, here's my question: which registry key contains the command line for .jar files?

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,789
    Rep Power
    25

    Default Re: double-cliick fails to run program.jar

    Find the entry for .jar. It has the key for the entry with the command lines. On my win7 system:

    The .jar entry:

    [HKEY_CLASSES_ROOT\.jar]
    @="jarfile_MINE"

    Then the jarfile_MINE entry:

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\jarfile_MINE]
    @="Executable Jar File"

    [HKEY_CLASSES_ROOT\jarfile_MINE\shell]

    [HKEY_CLASSES_ROOT\jarfile_MINE\shell\Check_Referen ces]
    "EditFlags"=hex:01,00,00,00
    @="Check References"

    [HKEY_CLASSES_ROOT\jarfile_MINE\shell\Check_Referen ces\command]
    @="java.exe -cp D:\\JavaDevelopment\\runtime\\CheckClassRefs.jar;. CheckClassRefs -jar \"%1\""

    [HKEY_CLASSES_ROOT\jarfile_MINE\shell\open]

    [HKEY_CLASSES_ROOT\jarfile_MINE\shell\open\command]
    @="\"C:\\Program Files\\Java\\jre6\\bin\\javaw.exe\" -jar \"%1\" %*"

    [HKEY_CLASSES_ROOT\jarfile_MINE\shell\open_in_1.7]

    [HKEY_CLASSES_ROOT\jarfile_MINE\shell\open_in_1.7\c ommand]
    @="\"C:\\Program Files\\Java\\jre7_7\\bin\\java.exe\" -jar \"%1\" %*"


    I use a unique name to keep installs from replacing my entry which has several right-click items.
    Last edited by Norm; 01-31-2013 at 02:31 AM.
    If you don't understand my response, don't ignore it, ask a question.

  12. #12
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Red face Re: double-cliick fails to run program.jar. SOLUTION

    [QUOTE=Norm;320403]Find the entry for .jar. It has the key for the entry with the command lines. On my win7 system:

    [HKEY_CLASSES_ROOT\.jar]
    @="jarfile_MINE"

    Then the jarfile_MINE entry:
    ...
    [HKEY_CLASSES_ROOT\jarfile_MINE\shell\open\command]
    @="\"C:\\Program Files\\Java\\jre6\\bin\\javaw.exe\" -jar \"%1\" %*"

    Curious. My registry has corresponding entries. No mention of runjar.exe. But for sure, runjar.exe is being run for .jar files. Sigh. My entries:

    [HKEY_CLASSES_ROOT\.jar]
    @="jar_auto_file"

    [HKEY_CLASSES_ROOT\jar_auto_file]

    [HKEY_CLASSES_ROOT\jar_auto_file\shell]

    [HKEY_CLASSES_ROOT\jar_auto_file\shell\open]

    [HKEY_CLASSES_ROOT\jar_auto_file\shell\open\command]
    @="\"C:\\Program Files\\Java\\jdk1.7.0_11\\jre\\bin\\java.exe\" \"%1\""
    NOTE MISSING "-jar"

    I added the missing "-jar"
    and double-click now runs .jar files.
    Without runjar.exe


    To find how the file association is working, I searched the registry for runjar.
    Its all over the place. The operative entries seem to be

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\ApplicationAssociationToasts]
    ...
    "Applications\\runjar.exe_.jar"=dword:00000000
    ...

    [HKEY_CURRENT_USER\Software\Classes\Applications\ru njar.exe\shell\open\command]
    @="\"U:\\Fred\\java\\Tools\\runjar.exe\" \"%1\""

Similar Threads

  1. Program fails to compare a String Token with a String.
    By yasarqamar in forum New To Java
    Replies: 4
    Last Post: 07-11-2012, 01:42 PM
  2. How to make java program run from a double click.
    By spas87 in forum New To Java
    Replies: 1
    Last Post: 12-14-2011, 06:17 PM
  3. The below program fails and throws an exception
    By frintocf in forum New To Java
    Replies: 1
    Last Post: 10-04-2011, 10:41 AM
  4. double a * double b = weird output
    By GPB in forum New To Java
    Replies: 3
    Last Post: 03-26-2010, 11:40 AM
  5. Double.valueOf() vs Double.parseDouble()
    By greenbean in forum New To Java
    Replies: 10
    Last Post: 01-12-2009, 09:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •