- NSIS Discussion
- Help with classpath and jars - JAVA
Archive: Help with classpath and jars - JAVA
pgg1
25th October 2007 17:49 UTC
Help with classpath and jars - JAVA
Hi Guys
look at the following line:
CreateShortCut "$SMPROGRAMS\${ZANG}\${ZANG}.lnk" "${JAVA_EXE}" "-cp ./Client/a.jar;./Client/b.jar;./Client/c.jar;./Client/d.jar;./Client/e.jar com.kc.pm.Main" "${SOME_ICON}" ""
This works fine. However if I add another 7 jars to the classpath:
CreateShortCut "$SMPROGRAMS\${ZANG}\${ZANG}.lnk" "${JAVA_EXE}" "-cp ./Client/a.jar;./Client/b.jar;./Client/c.jar;./Client/d.jar;./Client/e.jar;./Client/f.jar;./Client/g.jar;./Client/h.jar;./Client/i.jar;./Client/j.jar;./Client/k.jar;./Client/l.jar com.kc.pm.Main" "${SOME_ICON}" ""
This doesn't work. I've noticed that It breaks after adding the 10th jar. When I add the 10th jar it effects the desktop and quick launch icons as well.
Is the string above too long for NSIS? I have no idea. If i run all the jars using a batch file the program runs correctly.
ps. I've renamed the jars above for simplicity.
kichik
25th October 2007 19:25 UTC
The string isn't too long. The limit is 1024 characters. How exactly does it "break"? Does it not create the shortcut at all?
pgg1
25th October 2007 20:30 UTC
Thanks for the reply
If we can forget the desktop and quick launch icons and concentrate the start menu it makes its easier.
I have the following jars to put on the classpath.
(1) ./Client/a.jar
(2) ./Client/bjar
(3) ./Client/c.jar
(4) ./Client/d.ar
(5) ./Client/e.ar
(6) ./Client/f.jar
(7) ./Client/g.jar
(8) ./Client/h.jar
(9) ./Client/i.jar
(10) ./Client/j.jar
(11) ./Client/k.ar;
(12) ./Client/l.jar
The first five work as expected and the application runs. However, we are now adding new functionality and are using some API's which are the jars (6 -> 12)
The problem is I can add an ANY additional 4 jars (from 6 -> 12) making a total of 9 jars and the login screen of the app loads. The moment I add the tenth jar
which can be ANY jar from the remaining 3 jars the icon on the start menu is lost and the app cannot start.
The message I get back is from the Java Virtual Machine saying "Could not find the main class. Program will exit."
If I add any more jars and try to run the app nothing happens at all.
With 9 it looks like this:
CreateShortCut "$SMPROGRAMS\${ZANG}\${ZANG}.lnk" "${JAVA_EXE}" "-cp ./Client/a.jar;./Client/b.jar;./Client/c.jar;./Client/d.jar;./Client/e.jar;./Client/f.jar;./Client/g.jar;./Client/h.jar;./Client/i.jar com.kc.pm.MyApp" "${ZANG_ICON}" ""
And 10 I add one more
If I run a batch file from the Client directory of the installation (where all the jars have been copied to):
java -cp ./a.jar;./b.jar;./c.jar;./d.jar;./e.jar;./f.jar;./g.jar;./h.jar;./i.jar;./j.jar;./k.jar;./l.jar com.kc.pm.MyApp
It works as expected.
pgg1
25th October 2007 20:33 UTC
Sorry I forgot to mention that when I say the "icon on the start menu is lost" I mean it's there but it's not my icon, It's an icon that Windows gives it when it can't find a suitable file type. I can still select the menu item.
Cheers.
pgg1
26th October 2007 10:23 UTC
BUG - NSIS CAN ONLY TAKE 9 JARS
Hi
I have solved my problem. NSIS can only take 9 jars after that something breaks. Initially I had 12 jars and was having problems. I then put 4 of the jars into one of the existing jars reducing the overall jar count to 8. This solved my problem.
Cheers.
mannaking
26th October 2007 10:59 UTC
You can use a batch file (.bat) to resolve this problem.
kichik
26th October 2007 11:22 UTC
NSIS doesn't know what a Jar is, so the problem can't be the number of Jars, but something deeper. What does the properties of the shortcut show when you create a non-functional shortcut? Would it possible to show the real CreateShortcut line?
pgg1
26th October 2007 14:02 UTC
My Create Shortcuts looks like:
Section "Create Shortcuts"
CreateDirectory "$SMPROGRAMS\${ZANG}"
CreateShortCut "$SMPROGRAMS\${ZANG}\${ZANG}.lnk" "${JAVA_EXE}" "${PARAMETERS}" "${ZANG_ICON}" ""
WriteINIStr "$SMPROGRAMS\${ZANG}\ZangBeZang.url" "InternetShortcut" "URL" "http://www.someAddress.com/"
CreateShortCut "$SMPROGRAMS\${ZANG}\Uninstall ${ZANG}.lnk" "${UNINSTALLER}"
SectionEnd
PARAMETERS is defined as:
"-cp ./Client/BrowserLauncher2-10rc4.jar;./Client/Connected.jar;./Client/flickrapi-1.0b4.jar;./Client/jdic.jar;./Client/jh.jar;./Client/jregex1.2_01.jar;./Client/JSON.jar;./Client/mail.jar;./gdata-client-1.0.jar;./gdata-core-1.0.jar;./gdata-media-1.0.jar;./gdata-youtube-1.0.jar com.kc.pm.MyAPP"
The last four jars had to be removed and placed into Connected.jar
Cheers,
Paul
pgg1
26th October 2007 14:04 UTC
Sorry I've pasted the last four jars in and forget the client directory. The problem still occurs though.
kichik
26th October 2007 19:20 UTC
Could you attach a complete piece of code that'd reproduce this. I can't reproduce this with the code you've posted.
pgg1
29th October 2007 13:38 UTC
In order for your to reproduce the problem I would have to give you our proprietary jars, which of course I can't. Once we have an obfuscater in place I will send everything over to you.
Cheers
kichik
29th October 2007 19:46 UTC
Why would I need the JAR files if the problem is in the shortcut itself?
pgg1
29th October 2007 23:08 UTC
So you can reproduce it.
I've already posted the shortcut code as requested. That's it, there's nothing more to add regarding shortcuts apart from the quick launch and desktop icons but I've temporarily commented them out. I don't believe posting any more of my script will be helpful.
All the jars are in the same directory before I build my installer and they are in the same directory after the installer has done it's stuff.
I don't think there is anything wrong with the shortcut and nobody has told me otherwise. How can the shortcut work up to and including the 9th jar but when I add the 10th jar it falls apart. However, the jars works perfectly when running from a batch file (from the install directory), or the jars work perfectly when I add 4 jars into one of the other jars, therefore reducing the overall jar count to 8 and below the 9 jar threshold.
I take on board that NSIS has no concept of a jar but I don't know what to think at the moment. It's just strange behaviour.
Cheers.
kichik
3rd November 2007 10:52 UTC
Well, not exactly. I don't have the exact code to create the shortcut as I don't have the definition of all those constants you've used there. PARAMETERS might also be defined differently than I assume.
But the longer this thread goes, it seems more and more like a problem with the something else than the shortcut. I'd start by debugging the executed program if I were you. You can start with a simple Process Explorer examination to make sure it got the command line right and go as far as debugging your main function in your JAR. As long as the icon is created and its properties are fine, I can't say much.