I have a java program that works correctly when I run java -jar "lizzie.jar"
from the terminal, but when I double click it in Nautilus it runs (i.e. UI shows) but returns the error "No such file or directory" for one of the files (./leelaz) it depends on to work properly.
I have created a .desktop file in /home/username/.local/share/applications
with the following contents:
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Lizzie
Type=Application
Exec=java -jar "/home/username/opt/Lizzie/lizzie.jar"
Icon=/home/username/opt/Lizzie/lizzie_custom_logo.png
Comment=Lizzie
Terminal=false
Running this yields the same error as double-clicking.
I found and read this post, and I've tried using both Terminal=true
and Terminal=false
. The file lizzie.jar is set to allow executing as program and both when running from Nautilus and terminal I am not root. This might of course be an issue for Lizzie and not Ubuntu, but I think I should be able to generate the same behavior as if run from terminal.
Dist: Ubuntu 18.04.6 LTS;
Kernel: 5.4.0-99-generic
java -version
returns:
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)
Question: What is the likely reason the behavior from double-clicking and running the .desktop is different from terminal, and how may I configure a .desktop file that gives exactly the same behavior as if I ran java -jar lizzie.jar
from the terminal?
N.B. The program runs in both cases, but it can't access the dependency ./leelaz
in the case of double-clicking or using .desktop. Lizzie then reports: Cannot run program "./leelaz": error=2, No such file or directory.
But, the file ./leelaz
is there, and again, everything works when run from terminal.
(In case of interest, the application is Lizzie, an interface for the Go AI Leela Zero.)