1

I have a problem with an executable jar file. When I launch my jar file with Windows command line, all is good :

java -jar updater.jar

When I double click on my jar file, nothing happens.

This problem appeared when I added graphic support to my application (org.eclipse.jface and org.eclipse.swt).

My MANIFEST.MF :

Main-Class: Updater
Class-Path: libs/

Thank you in advance

Nicolas
  • 19
  • 4
  • What command do you have associated with opening Jar files? – tobias_k Jul 18 '14 at 10:56
  • None. I generated jar file with eclipse (export -> runnable jar file). I want open it with double click on jar file. – Nicolas Jul 18 '14 at 10:59
  • Try from the commandline (java -jar myjar.jar) or set WIndows to open with java instead of javaw. – Thorbjørn Ravn Andersen Jul 18 '14 at 11:13
  • 1
    Would http://stackoverflow.com/q/8511063/6309 help? – VonC Jul 18 '14 at 11:13
  • With the command line, my jar works fine. If I launch my jar with a .bat file and the command java -jar updater.jar, it works fine. But not with double click. I read the thread proposed by VonC. Symptom are same, but my file is correctly associated with javaw. I try with java : a commands line opens and close immediatly, and nothing else happens. – Nicolas Jul 18 '14 at 11:33
  • If the doubleclick doesn't work then the `.jar` extension is not registered or not registered correctly in the system. What does `assoc .jar` show you? Is there a `ftype` entry for jarfiles? –  Jul 18 '14 at 12:04
  • "but my file is correctly associated with javaw". How did you verify that? The class-path looks incomplete in any case; I would expect your eclipse jars to be listed in there. – Gimby Jul 18 '14 at 12:04
  • @a_horse_with_no_name : `assoc .jar`show me `.jar=jarfile`. `ftype jarfile` show me `jarfile="C:\Program Files (x86)\Java\jre7\bin\javaw.exe" -jar "%1" %*` => 32 bit JRE. My application is compiled with 64 bit JDK. I try to change `ftype`, but : `Access Denied`... – Nicolas Jul 18 '14 at 12:15
  • @a_horse_with_no_name : I edit my first comment. – Nicolas Jul 18 '14 at 12:18
  • @Gimby : I verify it with right click, open with... – Nicolas Jul 18 '14 at 12:19
  • Do you actually _have_ Java installed in `C:\Program Files (x86)\Java\jre7` ? –  Jul 18 '14 at 12:36

2 Answers2

0

It will not open with double click, because that would be like you typing javaw updater.jar in cmd. The thing you need to do is write a wrapper for the thing. Maybe VisualBasic as it is easy to understand. You can write an updater in it and use AmazonAWS to host your update files. That's what I do, and I reccomend you to do that too.

Roberto Anić Banić
  • 1,411
  • 10
  • 21
0

Solution (thx a_horse_with_no_name for clues) :

With an application which use platform dependent component (like org.eclipse.swt.win32.win32.x86_64_3.102.1.v20130827-2048.jar), set ftype jarfile to JRE that correspond to your architecture (32 or 64 bit) in commands line prompt (run as administrator) :

ftype jarfile="C:\Program Files (x86)\Java\jre7\bin\javaw.exe" -jar "%1" %*

or

ftype jarfile="C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*

All works fine now, thank you !

Nicolas
  • 19
  • 4
  • A Java program is not "compiled" for a specific architecture. Code that is generated with a 64bit JDK can run on a 32bit JVM without problems. –  Jul 18 '14 at 12:36
  • That depends. I use, in my application, `org.eclipse.swt.win32.win32.x86_64_3.102.1.v20130827-2048.jar`. According to his name, this jar seems platform dependent. No ? When I transform my application to don't use this jar, my application works fine on 32 bits and 64 bits JRE. – Nicolas Jul 18 '14 at 12:44
  • Ah, yes. SWT is not pure Java (unlike Swing). In that case it indeed depends on the architecture (one of the reasons I avoid SWT) –  Jul 18 '14 at 12:45