Search code examples
javadesktop-applicationexecutable-jarubuntu-18.04gnome

Gnome desktop file does not run "java -jar" command


I wrote an application with JavaFX and I would like to run it like a "native" app in Ubuntu.

So I created the following desktop file and put it in ~/.local/share/applications:

[Desktop Entry]
Name=Notes
Exec=java -jar /home/namhto/dev/Notes/build/libs/notes-1.0.0.jar
Icon=/home/namhto/dev/Notes/build/libs/icon.png
Type=Application
Terminal=false

The desktop icon is created but when launching it from the gnome desktop, nothing happens. Running the command java -jar /home/namhto/dev/Notes/build/libs/notes-1.0.0.jar from a terminal effectively starts my app.

I tried to mark the jar file as executable in Ubuntu but it does not change anything.


Solution

  • I would start with using /the/absolute/path/to/java for your exec command (which you can find out via which java for example), instead of a relative one. Maybe your ENV setup doesn't have java in $PATH somehow.

    Anything else looks good to me.