Archive: 2 Java Launcher Example Files Question


2 Java Launcher Example Files Question
Hello everyone,

I am entirely new to NSIS. I downloaded it two days ago. I researched the docs offline. Today I registered for this forum. I was really looking for a way to create a java launcher. So, this is my first post.

I found two java example files, I used the one that deals with the javaw.exe at nsis.sourceforge.net/A_slightly_better_Java_Launcher, and the other one that used the java.exe nsis.sourceforge.net/Java_Launcher, but I was unsuccessful compiling the first example {that deals with javaw.exe}.

I then used the one that deals with java.exe example which worked, and I edited it, replacing java.exe with javaw.exe in every instance I found. [I hope I am making this point very clear.]

Here is the file that has been edited:

; Java Launcher
;--------------

Name "Java Launcher"
Caption "Java Launcher"
Icon "modern-install.ico"
OutFile "Java Launcher.exe"

SilentInstall silent
AutoCloseWindow true
ShowInstDetails nevershow

!define CLASSPATH ".;lib;lib\HyperLink.jar"
!define CLASS "Demo"

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 (javaw.exe)
; 1 - in .\jre directory (JRE Installed with application)
; 2 - in JAVA_HOME environment variable
; 3 - in the registry
; 4 - assume javaw.exe in current dir or PATH

Push $R0
Push $R1

ClearErrors
StrCpy $R0 "$EXEDIR\jre\bin\javaw.exe"
IfFileExists $R0 JreFound
StrCpy $R0 ""

ClearErrors
ReadEnvStr $R0 "JAVA_HOME"
StrCpy $R0 "$R0\bin\javaw.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\javaw.exe"

IfErrors 0 JreFound
StrCpy $R0 "javaw.exe"

JreFound:
Pop $R1
Exch $R0
FunctionEnd

___________

Although I can successfully create a launcher with that modified code, an error message window would report: "Could not find the main class. Program will exit"

By the way, I am dealig with an executable jar file found at java-forum.org/de/userfiles/user3690/HyperLink.jar on Sun's website. Needless to say, it is a single jar file.

I suspect, that the errors occur between lines 13 to 21 that code above. The main class is "Demo.class"

The sample executed jar file GUI can be seen with the screen shot attached. The same should also be the case when executing the launcher.

I would appreciate any help from anyone concerned.

Oliver Bob Lagumen


I found the answer

!define CLASSPATH ".;lib;lib\HyperLink.jar"
!define CLASS "Demo"

Should be written this way:

!define CLASSPATH ".;lib;lib\HyperLink.jar"
!define CLASS "demo.Demo"

Since the META-INF specifies it so.