2

I am trying to run a shell script with a .desktop file but it doesn't seem to work, producing an error of There was an error launching the application at each attempt. I have the sh and .desktop files set the executable.

.desktop file:

[Desktop Entry]
Name=Craftbukkit Server
Comment=run server
Exec="/home/ubuntu-gnome/Documents/Craftbukkit/run.sh"
Icon=/home/ubuntu-gnome/Documents/Craftbukkit/craftbukkit.png
Terminal=true
Type=Application

The script:

#!/bin/bash
/usr/bin/java -Xmx1024M -Xms1024M -jar /home/ubuntu-gnome/Documents/Craftbukkit/craftbukkit.jar -o false

All paths are correct.

Methods I Have Tried:

  • Exec="/home/ubuntu-gnome/Documents/Craftbukkit/run.sh"
  • Exec='/home/ubuntu-gnome/Documents/Craftbukkit/run.sh'
  • Exec=/home/ubuntu-gnome/Documents/Craftbukkit/run
  • Exec="/home/ubuntu-gnome/Documents/Craftbukkit/run.sh"
  • Exec=gnome-terminal -e "/home/ubuntu-gnome/Documents/Craftbukkit/run.sh"
  • Exec=bash -c 'cd /home/ubuntu-gnome/Documents/Craftbukkit/ && ./run.sh'

Conspicuously, I have tried many methods. Can anyone assist me with a resolution to this?

  • 1
    First question: does the script work when you run it from a terminal window? – Jacob Vlijm Oct 29 '14 at 7:30
  • Yes It does. I have been using it from the terminal with ./run.sh for many months now. – user271219 Oct 29 '14 at 12:01
2

Few potential issues:

  1. Your script needs a shebang on its first line... it should look like:

    #!/bin/bash
    /usr/bin/java ...
    
  2. Your script needs to be marked as executable:

    chmod +x /path/to/script.sh
    
  3. Your .desktop file also needs to be executable (security policy stuff apparently):

    chmod +x /path/to/desktop-file.desktop
    
  • Regarding step 3. why question: Permission of a .desktop file – blade19899 Oct 29 '14 at 12:29
  • The last one should not be necessary when run from Dash and stored in ~/.local.share/applications or /usr/share/applications (not on my system anyway) – Jacob Vlijm Oct 29 '14 at 12:29
  • Still produces the same error. – user271219 Oct 29 '14 at 12:39
2

This is what I would use for creating the ".desktop" file:

#!/usr/bin/env xdg-open    
[Desktop Entry]
Version=1.0
Type=Application
Name=MY APPLICATION NAME
Comment=THINGS I HAVE TO SAY ABOUT THE APPLICATION
Exec=sh -c "cd /PATH_TO_SH_FILE_FOLDER; FILENAME.sh"
Categories=ENGINERRING;GRAPHICS;ETC
Icon=/PATH_TO_ICON_IMAGE_FILE

For above, change the all-capital portions of the code to fit your context (which doesn't have to be all-capital). You can add Terminal = true if you want to see the terminal window.

Modified from an answer I gave to a related question here: Link to .exe doesn't launch Wine

  • that is just replacing in OP's last attempt "&&" by ";". won't change anything. – Jacob Vlijm Oct 29 '14 at 12:58
  • Whoops, my bad. Thanks @JacobVlijm for pointing out. Glad it is sorted out anyway. – Ronald Chua Oct 29 '14 at 13:11
0

Try to use always abolute paths in those scripts. Find out what path the java executable has with:

which java

Then use that as the path in yout script:

/path/to/java -Xmx1024M -Xms1024M -jar /path/to/craftbukkit.jar -o false

Note that you also should give the complete path to craftbukkit.jar.

0

Thank's Everyone for the help. I realized that I had something wrong with my .desktop file. I noticed that the properties of the .desktop file were different to that of the other .desktop files in /usr/share/applications, in it that there were no Description, Command or Comment text areas in mine.

I saved the .desktop file of Color Picker to the desktop and I substituted my information in, which made it work.

This is what the properties->Basic of the .desktop file is.

properties

The Script

[Desktop Entry] 
Name=Minecraft-Server Comment=Run the Minecraft
Craftbukkit Server
Icon=/home/ubuntu-gnome/Documents/Craftbukkit/craftbukkit.png
Exec='/home/ubuntu-gnome/Documents/Craftbukkit/run.sh' 
Terminal=true
Type=Application 
Categories=Minecraft;Server;CraftBukkit;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy