Ubuntu – Can’t create .desktop launcher for XMind

launcher

I downloaded and installed XMind, it came as a .zip folder as opposed to .deb file which means I had to install it using a bash script.

I put the extracted files into a temporary folder called .installed in my home folder.

I'm trying to create a desktop launcher for the executable that came with the installation at /home/user01/.installed/xmind-8-linux/XMind_amd64/XMind.

I created a .desktop file like this:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/user01/.installed/xmind-8-linux/XMind_amd64/XMind
Name=XMind
Comment=Mind mapping software
Icon=/home/user01/Pictures/Icons/new_branding_new_logo.png

And I placed it in /usr/share/applications/.

The problem is that whenever I try to run the application I get this error:

enter image description here

Clicking on the executable directly launches the application normally and the error is the same regardless of who owns the file (root or user) so I don't understand what I'm doing wrong. Any advice would be great.

Also, the error log says this:

!SESSION 2016-11-16 14:14:38.215 -----------------------------------------------
eclipse.buildId=R3.7.0.201611010032
java.version=1.8.0_111
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_GB
Command-line arguments:  -os linux -ws gtk -arch x86_64 -data ../workspace

!ENTRY org.eclipse.osgi 4 0 2016-11-16 14:14:38.410
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:78)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)

Update:
Running ./XMind from the terminal works as expected.
Running the whole path /home/user01/.installed/xmind-8-linux/XMind_amd64/XMind creates an error.
When the error happens the application creates a configuration folder in ~/ directory, which is normally located in the same folder as the executable. I still don't understand what's happening here.

Solution:

(Thanks to Katu) This is how I managed to solve the problem:

Create a bash script in the same location as the executable called xmind.sh

Enter inside the file:

#!/bin/bash

(cd /home/user01/.installed/xmind-8-linux/XMind_amd64/ && ./XMind)

Create a .desktop launcher with the new script instead of the executable.

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/user01/.installed/xmind-8-linux/XMind_amd64/xmind.sh
Name=XMind
Comment=Mind mapping software
Icon=/home/user01/Pictures/Icons/new_branding_new_logo.png

Best Answer

When you run it as ./Xmind, your current directory is the same directory as the Xmind executable. To duplicate that effect in a .desktop file, add a Path= line to set the working directory:

Path=/home/user01/.installed/xmind-8-linux/XMind_amd64/

For more information, see the .desktop file specification on what the Path entry does.


I'd also recommend moving the .desktop file from /usr/share/applications to /home/user01/.local/share/applications/, since, if you store the application within your home directory, it's probably an application just for you, rather than all users on the system.

Related Question