Results 1 to 12 of 12
- 01-23-2013, 07:22 AM #1
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
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:
The manifest file has got a Main-Class declaration:Java Code:java -jar program.jar
Windows 8 is vastly "simplified" in file association setting. There seems to be nothing I can do.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
Have you any ideas that might help???
- 01-23-2013, 03:46 PM #2
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.
- 01-24-2013, 06:10 PM #3
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
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.
- 01-25-2013, 08:38 AM #4
Member
- Join Date
- Feb 2012
- Posts
- 19
- Rep Power
- 0
Re: double-cliick fails to run program.jar
of the above suggestion doesn't work, try reinstalling java and it will automatically set default
- 01-29-2013, 11:56 PM #5
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
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
This is exactly the same error I get when I give the commandJava Code:Error: Could not find or load main class 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.Java Code:java u:\Fred\java\test\dist\test.jar
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.
- 01-30-2013, 02:45 AM #6
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.
- 01-30-2013, 04:37 AM #7
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
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:
Compiled with "cc -o runjar.exe runjar.c" if you happen to have cygwin installed. (Attaching does not seem possible at the moment.)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); }
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.
- 01-30-2013, 04:39 AM #8
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
- 01-31-2013, 12:36 AM #9
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.
- 01-31-2013, 12:54 AM #10
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
- 01-31-2013, 01:23 AM #11
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 01:31 AM.
If you don't understand my response, don't ignore it, ask a question.
- 01-31-2013, 02:55 AM #12
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 284
- Rep Power
- 4
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
-
Program fails to compare a String Token with a String.
By yasarqamar in forum New To JavaReplies: 4Last Post: 07-11-2012, 12:42 PM -
How to make java program run from a double click.
By spas87 in forum New To JavaReplies: 1Last Post: 12-14-2011, 05:17 PM -
The below program fails and throws an exception
By frintocf in forum New To JavaReplies: 1Last Post: 10-04-2011, 09:41 AM -
double a * double b = weird output
By GPB in forum New To JavaReplies: 3Last Post: 03-26-2010, 10:40 AM -
Double.valueOf() vs Double.parseDouble()
By greenbean in forum New To JavaReplies: 10Last Post: 01-12-2009, 08:39 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks