Score:0

Add a java application to the gnome menu

mw flag

I have a .jar application and I wanna add it to the gnome menu to run it from there, it must run with root privileges.

I did a file called java_application.desktop in /usr/share/applications. The content of the file:

[Desktop Entry]
Name=Java app
GenericName=My java app
Exec=Exec=gnome-terminal -x 'sudo java -jar .tlauncher/TLauncher-2.8.jar'
Icon=/usr/share/icons/Papirus/64x64/apps/java.svg
Type=Application
Terminal=true
StartupNotify=true
Categories=Games

If I execute the command: sudo java -jar .java_projects/java_app.jar in the terminal it works.

I've followed the suggestion of @jpbrain. Now the terminal opens, asks for the sudo password and the app opens... but closes after some seconds.

Gnome 40, Fedora 34 (I know it's a Ubuntu forum but I think you can help with this as the problem is about Gnome)

jpbrain avatar
ca flag
Hi @Gaspar. I understand sudo will not work within the .desktop file. Elevation of credentials has to be handled by the app.
jpbrain avatar
ca flag
try replacing: Exec=gnome-terminal -x 'sudo java -jar .java_projects/java_app.jar'
evening_g avatar
mw flag
I've updated the question
jpbrain avatar
ca flag
I did checkit. It is a problem with the app itself. It chrashes with sudo. Even if you put that absolute path it loads and then exits. When you do it without sudo it works.
evening_g avatar
mw flag
Thanks, now it works
Score:0
de flag

Install the software Menu editor. Open the software and click the '+' on the left top corner to add a launcher. Paste the command

sudo java -jar .tlauncher/TLauncher-2.8.jar 

in the empty box against the 'command.' Slide the radio button of 'Run in terminal' to on. On the menu bar, there is a right-pointed triangle icon and that can be clicked to test the launcher. You may change the icon and the description of the software

evening_g avatar
mw flag
It just keeps saying that the program cannot be found...
drpjkurian avatar
de flag
Hmm, that means the path to the executable file is wrong. I have changed the path in the answer.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.