|
|
|
|
Re: Creating an executable icon [message #675405 is a reply to message #672241] |
Tue, 31 May 2011 12:33 |
ouri.maler Messages: 22 Registered: July 2010 |
Junior Member |
|
|
Paul Webster wrote on Fri, 20 May 2011 08:43It works the same way on linux. Associating "java -jar" with .jar files will launch the jar with java on any double-click (desktop or system file browser)
PW
Wouldn't that work only on my machine, though? I need it to also work for clients who download the thing...
Anyway, tried a different approach: Created a shell script "script.sh" that executed the .jar, then created a desktop launcher designed to execute script.sh; this worked fine, except for one problem: its command was "/home/omaler/[...]/script.sh"; in other words, it was designed to work with the folder hierarchy specific to my machine. So I tried instead to make it more universal, by making it execute the script found in the same folder (rather than giving it an absolute path):
command: $(dirname %k)/script.sh
work path: ./
While it did launch the program...It encountered execution errors I never had while launching it with Eclipse or with the previous launcher. No idea how that's even possible.
So, I tried to obtain more data on the error by going into the launcher's advanced options, and checking the "run in terminal" option. But then, when I tried to run it and it opened a terminal...the only message it printed was that it couldn't find the .jar file. I tried checking the "run in terminal" option with the other launcher (the one using an absolute path, which worked just fine), and got the same error.
I'm...stumped. Maybe it's my ignorance of Linux launchers, but I don't understand where these errors could come from.
|
|
|
Re: Creating an executable icon [message #675415 is a reply to message #675405] |
Tue, 31 May 2011 13:10 |
|
Ouri.maler.gmail.com wrote on Tue, 31 May 2011 08:33
Wouldn't that work only on my machine, though? I need it to also work for clients who download the thing...
For executable jars to work, every client must make sure "java -jar" is used to execute jars.
Quote:
Anyway, tried a different approach: Created a shell script "script.sh" that executed the .jar ...
To create that kind of script reliably, you need something like:
#!/bin/bash
PROG=$0
PROG_DIR=$( dirname $( readlink -f "$PROJ" ) )
java -classpath "$PROG_DIR/lib1.jar:$PROJ_DIR/lib2.jar" com.example.MyMain
the first 2 lines make sure you have the path to your script directory, regardless of how the script is executed.
As for your foray into linux launchers, if the trick of getting your script dir doesn't fix it you'll need to follow up with the linux launcher app guys.
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
Powered by
FUDForum. Page generated in 0.03898 seconds