0

I have the following problem: I wrote a program in Java for a community and they're trying to run it. They installed Java and tried double clicking it but nothing happened.

Under my remote supervision, we tried the following things:

  • Right click -> open with -> java(w)

  • Control Panel -> Default Programs -> Associate a file type or protocol with a specific program -> .jar -> \path\to\java\bin\java(w).exe

  • In CMD:

    assoc .jar=jarfile
    ftype jarfile="C:\path\to\java\bin\java(w).exe" -jar "%1" %*
    

All of the above once more after reinstalling java and rebooting, and also after deleting the registry key [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jar]

All of these were tried with java.exe and javaw.exe.

It works without a problem in cmd.exe with java -jar program.jar.

I also tried to create a batch file with

@ECHO OFF
java -jar program.jar

that is in the same directory as my program. We also tried to do java.exe -jar program.jar (in the batch file).

When we used java, a cmd window popped up but nothing else happened; with javaw nothing happened. It was just that the mouse cursor switched to the loading symbol and then changed back. Afterwards, there were no java processes.

EDIT

I had sent them an email where I told them to delete the jar and jar_auto_file classes from the registry in HKEY_CURRENT_USER/Software/Classes but it didn't help.

I just had another call with the community and I tried getting more information why the program crashes. So we added pause to the batch file but nothing special (considering the history of this pc) happened. The file looked like this:

@ECHO OFF
java.exe -jar progam.jar
pause

During the execution of this program, a console window popped up and disappeared once more. pause didn't work apparently...

I also tried to use cmd /k instead of pause or switched the last two lines (first cmd /k then java ...) to no avail.

The last try was starting cmd by hand and executing cmd /k program.bat (yes, the batch file) to see if it would give me an error message. But it simply repeated the path of the bat-file and that's it.

In the meantime, they installed java on a similarly configured pc and there, it worked like it normally would (java installed, double click on jar, done). So, I'm at the end of my wits, please tell me if you have any more ideas of what to test. Now it isn't so much about solving the problem for my customer but more a morbid interest in what the problem really is...

Armin
  • 101
  • 3
  • (1) You say you supervised them remotely.  I hate to insult anybody’s intelligence, but how sure are you that they are double-clicking correctly? (2) What, exactly, happened when you tried the things that you tried?  (I’m particularly interested in “Open With”.)  (3a) You almost never need to say `.exe`.  (3b) Putting the batch file in the same directory as the JAR file, by itself, does no good.  Try putting the path to the JAR file into the batch file; i.e., `@ECHO OFF` / `java -jar C:\Users\Armin\program.jar`.  (3c) Also, try adding a `pause` command to the end of the batch file. – Scott - Слава Україні Jul 08 '18 at 15:58
  • Please do not respond in comments; [edit] your question to make it clearer and more complete. – Scott - Слава Україні Jul 08 '18 at 15:58
  • P.S. As far as I know, `PATHEXT` has nothing to do with running programs through the GUI.  Am I wrong? – Scott - Слава Україні Jul 08 '18 at 15:58
  • @Scott I answered in comments because I'm going to test it, I haven't tested it, so I'm not going to include it as a tried path. It's the first time I heard of `PATHEXT`, so, I don't know... I'm sure it was correctly done because when we tried to do it with `java` instead of `javaw`, a CMD window popped up, which was mentioned in the question. The `pause` thing is actually a pretty good advice, thanks, I'll try that as well, maybe I can get more info this way... – Armin Jul 08 '18 at 16:02
  • Have you read [java - Unable to run .jar files by double-clicking them on Windows 7 - Super User](https://superuser.com/questions/1194758/unable-to-run-jar-files-by-double-clicking-them-on-windows-7)? – DavidPostill Jul 08 '18 at 16:52
  • @DavidPostill I found it during writing the question. But I feel like this isn't it, because java gets executed (cmd pops up if java.exe is used instead of javaw.exe) – Armin Jul 08 '18 at 16:54
  • `C:\path\to\java\bin\java(w).exe` is wrong. `java(w).exe` does not exist. It should be `C:\path\to\java\bin\javaw.exe` – DavidPostill Jul 08 '18 at 16:55
  • @DavidPostill it is just a shorthand that I tested both java.exe and javaw.exe... – Armin Jul 08 '18 at 16:56
  • [java - How to run .jar file by double click on Windows 7 (64) - Stack Overflow](https://stackoverflow.com/questions/8511063/how-to-run-jar-file-by-double-click-on-windows-7-64) – DavidPostill Jul 08 '18 at 16:57
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/79899/discussion-between-armin-and-davidpostill). – Armin Jul 08 '18 at 16:57
  • @Scott ok, we've tried it now with `pause` but with double click, it just did the same, we used `java.exe` in the execution and a console window popped up and closed itself immedtiately. I then tried it with `cmd /k program.bat` and no error messages were printed... I don't know what happened to the java installation on this pc but apparently nothing works there -.- (I add this information to the question as well, just wanted to tell you) – Armin Jul 09 '18 at 10:28

0 Answers0