2

I have a .desktop file for a bash script, but when I launch the .desktop file nothing happens except that a terminal window is shown for half a second.

If I run the bash script directly (without the .desktop file), the script works fine (bash file is called 'minecraft'):

#!/bin/bash
java -Xmx1024M -Xms512M -cp minecraft.jar net.minecraft.LauncherFrame

The file is executable.

This is my minecraft.desktop file:

[Desktop Entry]
Type=Application
Name=Minecraft
Comment=Minecraft
Icon=/home/bram/Applications/Minecraft/icon.png
Exec=/home/bram/Applications/Minecraft/minecraft
Terminal=true
Categories=Minecraft;game

minecraft.desktop is located in ~/.local/share/applications

1
  • Thanks for posting your solution. You should move it to an answer and accept it, though, so your question shows up as answered. Aug 15, 2012 at 17:18

3 Answers 3

3

Apparently the script couldn't find the .jar file. When I run the bash file using the .desktop file, I assume it runs the bash file in the directory of the .desktop file (~/.local/share/applications).

When I give the full path name to the jar, it works fine:

#!/bin/bash
java -Xmx1024M -Xms512M -cp /home/bram/Applications/Minecraft/minecraft.jar net.minecraft.LauncherFrame
1

You have two options:

1.) Set the working directory in the .desktop file to the location of the .jar

2.) Use full paths in your Bash script (like you did)

1
  • How do you "set the working directory in the .desktop file" @user241583 ? I tried using WorkingDirectory=... and validator complained I was extending the spec without using an X- prefix.
    – NeilG
    Jul 24, 2021 at 7:34
0

You can run it as a background task:

#!/bin/bash
nohup java -Xmx1024M -Xms512M -cp minecraft.jar net.minecraft.LauncherFrame

(Note the nohup at the beginning used to make keep running)

8
  • Still nothing happens. The jar still isn't launched. Aug 15, 2012 at 12:19
  • Try removing the space right before the &.
    – nanofarad
    Aug 15, 2012 at 12:20
  • No, still nothing.. Aug 15, 2012 at 12:22
  • OK... Do you mind the script running at all times?
    – nanofarad
    Aug 15, 2012 at 12:23
  • Yes, the script opens a jar file (which is a game) and I don't want the game to be running all the time. Aug 15, 2012 at 12:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .