Creating an executable icon [message #671985] |
Thu, 19 May 2011 10:08  |
Eclipse User |
|
|
|
I'm currently part of a team designing a certain Java application; my part was coding a file called GUI.java, with which the entire program is launched. Now, it works fine when I launch it through Eclipse, but I would like to change it so that it can launched simply by clicking a desktop icon.
Can this be done with Eclipse? I've tried to use its "export" functionality to create a .jar, but I can only execute that by opening a command prompt and typing java -jar GUI.jar...
|
|
|
|
|
|
Re: Creating an executable icon [message #675405 is a reply to message #672241] |
Tue, 31 May 2011 08:33   |
Eclipse User |
|
|
|
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 #676795 is a reply to message #675415] |
Mon, 06 June 2011 10:46  |
Eclipse User |
|
|
|
Ended up with the following script:
#!/bin/bash
PROG=$0
PROG_DIR=$( dirname $( readlink -f "$PROG" ) )
java -jar "$PROG_DIR/GUI.jar"
An office colleague helped me run it in a terminal. Apparently, the exception occurs when it can't find "bin/oc_linux"; he says this is due to problems with selecting the right working directory.
|
|
|
Powered by
FUDForum. Page generated in 0.52279 seconds