Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (763)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (852)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Cannot run a program by clicking on its icon whereas it works in command line  (Read 5302 times)
0 Members and 1 Guest are viewing this topic.
Offline gouessej
« Posted 2015-10-29 22:21:44 »

Hi

Somebody tested my Debian packages today. She succeeded in running my game by entering "tuer" in command line but when she clicks onto the launcher in the "Applications" section under Ubuntu 14.04 LTS (with the desktop manager Unity), it doesn't run. xdg-open just opens the file in a text editor. "gtk-launch tuer" tells that there was an error at the creation of the child process "tuer", "no such file or directory" and "** (gtk-launch:27745): WARNING **: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.".

I use this script:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
#!/usr/bin/bash
#code snippet written by Dave Dopson: http://stackoverflow.com/a/246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
    APP_LAUNCHER_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
    SOURCE="$(readlink "$SOURCE")"
    [[ $SOURCE != /* ]] && SOURCE="$APP_LAUNCHER_DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
APP_LAUNCHER_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
$APP_LAUNCHER_DIR/jre/bin/java -server -Xmx256m -XX:MaxDirectMemorySize=128M -Djava.ext.dirs= -jar $APP_LAUNCHER_DIR/tuer.jar


I know that Ubuntu uses dash instead of bash by default but I expected to get a better error message.

Do you know a possible root cause of this bug? The packages are here:
http://tuer.sourceforge.net/en/play/

Julien Gouesse | Personal blog | Website | Jogamp
Offline gouessej
« Reply #1 - Posted 2015-10-30 09:24:57 »

Hi

I'm going to use a more simple script with some hardcoded paths so that it works both with /usr/bin/bash and /usr/bin/dash. I hope that it will solve my problem.

Julien Gouesse | Personal blog | Website | Jogamp
Offline gouessej
« Reply #2 - Posted 2015-10-30 13:46:34 »

Keeping the last line of the script and using absolute paths fix the problem.

Explanation: When using a terminal, "tuer" is looked for in the path, it's found in /usr/bin/, the first line of the script indicates that I use bash, the game starts, everything is ok. When clicking on the icon in the "Applications" section, gtk-launch or something similar in Unity ignores "#!/usr/bin/bash", complains internally because it uses dash by default and in the best case it just tells me than the child process of "tuer" has died.

Conclusion: Use a Posix subset of bash and dash and keep your scripts as simple as possible if you want to avoid such troubles. I thank the woman who helped me to verify my fix.

Julien Gouesse | Personal blog | Website | Jogamp
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline nsigma
« Reply #3 - Posted 2015-10-31 12:11:47 »

You may want to have a look at this "hideous" bit of script.  It's from the launcher code in NetBeans, which is also used in Praxis LIVE and that definitely works from a DEB in Ubuntu 14.04.  If you search for it you'll find it in use in various other places too.  It has the added benefit of working on OSX.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
PRG=$0

while [ -h "$PRG" ]; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
    if expr "$link" : '^/' 2> /dev/null >/dev/null; then
   PRG="$link"
    else
   PRG="`dirname "$PRG"`/$link"
    fi
done

progdir=`dirname "$PRG"`


btw - I don't think the warning message is relevant to your issue, and "no such file or directory" seems fairly self-explanatory.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline gouessej
« Reply #4 - Posted 2015-11-01 18:36:55 »

This script is nice, mine works under OS X too by the way.

Have you passed checkbashisms on it?

Julien Gouesse | Personal blog | Website | Jogamp
Offline nsigma
« Reply #5 - Posted 2015-11-02 10:05:37 »

This script is nice, mine works under OS X too by the way.

Ah, yes, sorry - obviously some uses of readlink don't work on OSX.

Have you passed checkbashisms on it?

No, but bear in mind this bit of script is also used every time someone uses NetBeans on Linux, OSX, or any other Unix.  And if you Google it you'll find it in use in lots of (particularly Java) projects, eg. -

https://github.com/krux/java8/blob/master/jdk1.8.0_45/bin/javapackager

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline gouessej
« Reply #6 - Posted 2015-11-02 15:22:57 »

This script is nice, mine works under OS X too by the way.

Ah, yes, sorry - obviously some uses of readlink don't work on OSX.
For example, readlink -f doesn't work under OS X, you're right.

You should mention this script here, shouldn't you?
http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in

Julien Gouesse | Personal blog | Website | Jogamp
Offline nsigma
« Reply #7 - Posted 2015-11-02 15:39:06 »


That would involve me having a stackoverflow account ... sign up ... question is locked to people without "reputation" ... give up on the whole pointless exercise  Emo

Feel free to mention it yourself - not like it's my code anyway!  Wink

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline gouessej
« Reply #8 - Posted 2015-11-02 17:00:07 »

I understand your position, I use Stackoverflow with OpenID. I'll mention it.

The script you suggest uses dirname which doesn't work everywhere too :s

Julien Gouesse | Personal blog | Website | Jogamp
Offline nsigma
« Reply #9 - Posted 2015-11-02 17:17:43 »

I understand your position, I use Stackoverflow with OpenID. I'll mention it.

Great!

The script you suggest uses dirname which doesn't work everywhere too :s

Really, where?  I thought dirname was part of POSIX?

Praxis LIVE - hybrid visual IDE for (live) creative coding
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #10 - Posted 2015-11-02 18:57:04 »

Someone complained because he obtained "dirname: not found" under Ubuntu 13.10, he probably used an unusual shell interpreter, it is far-fetched to me too. Anyway, readlink is part of POSIX too (but not all implementations conform to the standard).

Julien Gouesse | Personal blog | Website | Jogamp
Offline gouessej
« Reply #11 - Posted 2015-11-09 15:58:44 »

Hi

The shebang was causing some troubles too:
1  
#!/usr/bin/bash


I've replaced it by #!/bin/env bash in the scripts that really need Bash and by #!/bin/env sh for the others.

nsigma, as far as I know, the Java packager you quoted is unable to create Linux packages under Mac OS X and Windows unlike my own tool Smiley

Julien Gouesse | Personal blog | Website | Jogamp
Offline nsigma
« Reply #12 - Posted 2015-11-09 17:54:46 »

nsigma, as far as I know, the Java packager you quoted is unable to create Linux packages under Mac OS X and Windows unlike my own tool Smiley

No idea, don't use it!  I was just demonstrating that the script fragment posted earlier, used in both the NetBeans and Praxis LIVE launchers, is used in lots of other Java tools too.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (492 views)
2018-06-10 19:43:48

EgonOlsen (595 views)
2018-06-10 19:43:44

EgonOlsen (406 views)
2018-06-10 19:43:20

DesertCoockie (743 views)
2018-05-13 18:23:11

nelsongames (1016 views)
2018-04-24 18:15:36

nelsongames (981 views)
2018-04-24 18:14:32

ivj94 (1545 views)
2018-03-24 14:47:39

ivj94 (557 views)
2018-03-24 14:46:31

ivj94 (1295 views)
2018-03-24 14:43:53

Solater (560 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!