Search code examples
nsis

cannot open fat jar from a desktop shortcut


the fat jar opens fine in the location i specified but it wont open when i call it through a desktop shortcut. Although if I right click on the icon and say open file location, it opens the correct file.

SetOutPath $INSTDIR
SetOverwrite on
File C:\jitconsole\JITConsole\jitconsole.jar
SetOutPath $INSTDIR\images
File C:\jitconsole\JITConsole\images\*
SetOutPath $INSTDIR\lib
File C:\jitconsole\JITConsole\lib\*
SetOutPath $DESKTOP
CreateShortcut $DESKTOP\JIT.lnk $INSTDIR\jitconsole.jar "" $INSTDIR\images\JIT_medium.ico 

any help would be greatly appreciated thanks


Solution

  • A .jar could open in any application, on my system it is set to open in WinRar!

    You should create a shortcut that executes the correct command line:

    CreateDirectory $Desktop ; Make sure desktop exists
    SetOutPath $Instdir ; Sets the .lnk working directory
    CreateShortcut "$DESKTOP\JIT.lnk" "c:\path\to\java.exe" "$INSTDIR\jitconsole.jar" "$INSTDIR\images\JIT_medium.ico" 
    

    This means you need to figure out the java path in the installer and if the java path changes your shortcut might break. It is probably a better idea to use a java loader app:

    CreateDirectory $Desktop ; Make sure desktop exists
    CreateShortcut "$DESKTOP\JIT.lnk" "$INSTDIR\MyJavaLoaderForMyApp.exe" "" "$INSTDIR\images\JIT_medium.ico"