java - Why does my JAR file execute at CMD, but not on double-click? -


so i've been writing simple 3d gui application intended users use double-clicking on jar file. got working before putting jar file, , got working in jar file while running command prompt (typing "java -jar modeler.jar" while in directory of jar file). however, when double-click it, nothing happens. runs fine no errors command prompt. know experience crash reports on start-up not shown because console doesn't appear (or disappears fast), when running command prompt there no crash reports. ideas why won't work? i'm running windows 7 home premium. here contents of jar file if helps:

modeler.jar | +--*all class files necessary* | +--meta-inf    |    +--manifest.mf 

contents of manifest.mf:

manifest-version: 1.0 built-by: anonymousjohn class-path: bin/j3dcore.jar bin/j3dutils.jar bin/vecmath.jar created-by: 1.6.0_16 (sun microsystems inc.) main-class: start 

edit: after messing file associations use java.exe instead of javaw.exe (thereby providing window print-outs), modifying startup mechanism little print out current working directory, discovered jar running "c:\windows\system32" instead of folder on desktop put in. go figure. however, moving necessary outside files there doesn't anything.

edit 2: tried making jar file, time simple jframe button in tells current working directory. press button , opens (useless) jfilechooser. worked on double-click no matter put in computer. there must wrong jar file. i'll start troubleshooting program again.

edit 3: problem thought was: it's not loading libraries correctly when double click on it. weird part in tests display current path , library path, output same whether run via command prompt or via double-clicking on it. here's stack trace:

java.lang.unsatisfiedlinkerror: no j3dcore-d3d in java.library.path   @ java.lang.classloader.loadlibrary(unknown source)   @ java.lang.runtime.loadlibrary0(unknown source)   @ java.lang.system.loadlibrary(unknown source)   @ javax.media.j3d.nativepipeline$1.run(nativepipeline.java:231)   @ java.security.accesscontroller.doprivileged(native method)   @ javax.media.j3d.nativepipeline.loadlibrary(nativepipeline.java:200)   @ javax.media.j3d.nativepipeline.loadlibraries(nativepipeline.java:157)   @ javax.media.j3d.mastercontrol.loadlibraries(mastercontrol.java:987)   @ javax.media.j3d.virtualuniverse<clinit>(virtualuniverse.java:299)   @ javax.media.j3d.canvas3d.<clinit>(canvas3d.java:3881)   @ modelpreview.<init>(modelpreview.java:51)   @ modeler.<init>(modeler.java:76)   @ modeler.main(modeler.java:1227)   @ start.main(start.java:92) 

only problem is in library path. set in program. think may problem. set (this method found somewhere on internet. don't remember where):

//above code newpath based on operating system. //all code set in try-catch phrase. //reset library path system.setproperty("java.library.path", ".\\bin\\natives" + newpath + ";"); //make sure classloader rereads new path. field f = classloader.class.getdeclaredfield("sys_paths"); f.setaccessible( true ); f.set(null, null); //classloader automatically reread path when sees null.   

edit final: well, after looking , relooking @ code, discovered problem in bs'ery involving detection of 64-bit systems loading wrong dll's. why worked command-line , not via double-click don't know , never know, works via double-click now, i'm happy. sorry troubles.

ok, stuck on exact issue on week (it has been side project devote few hours day).

this happened on desktop, reason wouldn't happen on laptop.

after looking around, found answer , thought i'd share people me, found nothing useful in accepted answer here. credits go anonymous stack overflow user, whom username i've lost in excitement.

as mentioned other answer somewhere seeming unrelated issue, use little program associate jar files 64 bit version of java:

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

save program somewhere , run command line parameter /64: c://path//jarfix.exe /64

nothing else worked me, magic. :)


Comments