Archive: Executing a java JAR file after NSIS installation is complete


Executing a java JAR file after NSIS installation is complete
Hello, I have this slight problem. I have written an installer, which copies a JAR file called Konfigurator.jar to $INSTDIR/bin., NOw, what I want to do is to run this JAR file after installation is complete.
So I added the command:

Exec "$INSTDIR\bin\javaw.exe -jar Konfigurator.jar"

But it doesn't work. Please can anyone give me a tip on how to run the JAR file using javaw -jar, Please anyhelp is appreciated. This is also urgent. Thanks.


You forgot to quote the path to javaw.exe. It might contain spaces, so it must be quoted.


Please it doesn't work. Can you please tell me how to run a JAR file located in a specified folder using the NSIS Exec command or any other command. The system on which the jar file is to be run already has a JRE installed. Thank you very much.


You should locate javaw.exe at first. See the following code:

SearchPath $0 "javaw.exe"
StrCmp $0 "" 0 OK1 ; if javaw.exe in PATH
ReadRegStr $1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$1" "JavaHome"
StrCmp $0 "" Error OK2
OK1:
StrCmp $0 "javaw.exe -jar Konfigurator.jar"
Goto OK
OK2:
StrCmp $0 '"$0\javaw.exe" -jar Konfigurator.jar'
Goto OK
Error:
MessageBox MB_OK "javaw.exe does not exist!"
Abort
OK:
Exec $0


Yes, but the file Konfigurator.jar is in $INSTDIR\bin. How do I locate it and run, even if I find javaw.exe. thanks.


Originally posted by daibatzu
Yes, but the file Konfigurator.jar is in $INSTDIR\bin. How do I locate it and run, even if I find javaw.exe. thanks.
Exec 'javaw.exe -jar "$INSTDIR\bin\Konfigurator.jar"'

This is the exact command I have used and yet it does not work. I don't have a clue why not. Anyway, thanks for the help.


SearchPath $0 "javaw.exe"
StrCmp $0 "" 0 OK1 ; if javaw.exe in PATH
ReadRegStr $1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
ReadRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$1" "JavaHome"
StrCmp $0 "" Error OK2
OK1:
StrCmp $0 'javaw.exe -jar "$INSTDIR\bin\Konfigurator.jar"'
Goto OK
OK2:
StrCmp $0 '"$0\javaw.exe" -jar "$INSTDIR\bin\Konfigurator.jar"'
Goto OK
Error:
MessageBox MB_OK "javaw.exe does not exist!"
Abort
OK:
Exec $0

Thanks a lot hooklee, it works perfectly now