0

I have a simple Java program that interacts with the user in the CLI. The program runs fine from a shell script (play.sh), when the shell script is executed from the CLI.

Is there a way to rewrite the play.sh file to be able to run it from the Ubuntu Files via a double-click? I want the file to open a CLI session and then run the Java program from within that session. It would save me a small step if I could just double-click the play.sh file directly instead of first executing "Open In Terminal" and then typing ./play.sh from within a CLI session.

Text of the play.sh follows:

#!/bin/bash 

java -p ~/Projects_Java/src/FlashIntervals/compiled/ -m moduleFlashIntervals/seconditeration.CLIPrompter

Yes, the play.sh file properties include "Allow executing file as program". But the double-click appears to do nothing, probably because a CLI session is not opened by the Java program itself. The Java program simply writes to System.out.console, i.e., the CLI from where it was run. And there is nothing in the play.sh file to expose this session to the user.

This is almost certainly a duplicate question but I don't seem to be searching for an answer with the correct keywords, and can't find info on how to do this.

1 Answer 1

1

Just create a *.desktop file e.g. in ~/.local/share/application/myJava.desktop with the following exemplified content:

[Desktop Entry]
Name=My Java App
Type=Application
Exec=/home/username/play.sh
Terminal=true
Icon=/home/username/pictures/play.png
Comment=Executes my Java application
NoDisplay=false
Categories=Utility
Name[de_DE]=JavaApp

So when you search for this application in GNOME's search bar you should find it and execute it. Because you have configured the desktop file with Terminal=true a terminal should be opened.

2
  • I'm a bit confused, but part might be because I referred to Nautilus, which I now realize I'm not using. When you refer to GNOME's search bar, what are you referring to? It turns out that the utility being invoked for file folder navigation is the Files program. There is a field that opens when clicking an icon with a magnifying class. Is this the "search bar"? Can you direct me to documentation about this [Desktop Entry] functionality? Oct 22, 2022 at 23:37
  • 1
    The Gnome's search bar appears when you press the Super key (the windows key). The specification about the *.desktop files you'll find here Oct 24, 2022 at 7:45

You must log in to answer this question.

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