Java Launcher: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.) |
m (Updated author links.) |
||
Line 1: | Line 1: | ||
{|align=right | |||
|<small>Author: [[{{ns:2}}:Baz|Baz]] ([[{{ns:3}}:Baz|talk]], [[{{ns:-1}}:Contributions/Baz|contrib]])</small> | |||
|} | |||
<br style="clear:both;"> | |||
== Description == | == Description == | ||
Here is a NSIS script which can be used to launch Java programs the easy way. | Here is a NSIS script which can be used to launch Java programs the easy way. | ||
Line 76: | Line 80: | ||
FunctionEnd | FunctionEnd | ||
</highlight-nsis> | </highlight-nsis> | ||
Revision as of 02:59, 30 April 2005
Author: Baz (talk, contrib) |
Description
Here is a NSIS script which can be used to launch Java programs the easy way.
It will search for the JRE the following way:
1 - in jre directory (if you have JRE Installed with your application) 2 - in JAVA_HOME environment variable 3 - in the registry 4 - assume java.exe in current dir or PATH
In this example NSIS is not used as an installer but as a windows program.
There's no programming language out there in which it can be done this simple!
Have fun! (can you believe people want you to pay for this!)
The Script
; Java Launcher ;-------------- Name "Java Launcher" Caption "Java Launcher" Icon "Java Launcher.ico" OutFile "Java Launcher.exe" SilentInstall silent AutoCloseWindow true ShowInstDetails nevershow !define CLASSPATH ".;lib;lib\myJar" !define CLASS "org.me.myProgram" Section "" Call GetJRE Pop $R0 ; change for your purpose (-jar etc.) StrCpy $0 '"$R0" -classpath "${CLASSPATH}" ${CLASS}' SetOutPath $EXEDIR Exec $0 SectionEnd Function GetJRE ; ; Find JRE (Java.exe) ; 1 - in .\jre directory (JRE Installed with application) ; 2 - in JAVA_HOME environment variable ; 3 - in the registry ; 4 - assume java.exe in current dir or PATH Push $R0 Push $R1 ClearErrors StrCpy $R0 "$EXEDIR\jre\bin\java.exe" IfFileExists $R0 JreFound StrCpy $R0 "" ClearErrors ReadEnvStr $R0 "JAVA_HOME" StrCpy $R0 "$R0\bin\java.exe" IfErrors 0 JreFound ClearErrors ReadRegStr $R1 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion" ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\$R1" "JavaHome" StrCpy $R0 "$R0\bin\java.exe" IfErrors 0 JreFound StrCpy $R0 "java.exe" JreFound: Pop $R1 Exch $R0 FunctionEnd