.sh execution not happening, execution in Terminal ok

Under linux xfce,

executing the following in a terminal window is OK:

/usr/lib/jvm/java-8-openjdk/jre/bin/java -jar “/home/x245/appsJarPortable/searchmonkey-3.2.0-jar-with-dependencies.jar”

Now, if a create a searchMonkey.sh file under “/home/x245/appsJarPortable/” with:

#!/bin/bash
/usr/lib/jvm/java-8-openjdk/jre/bin/java -jar “/home/x245/appsJarPortable/searchmonkey-3.2.0-jar-with-dependencies.jar”

Then add to permissions: execute and finaly open searchMonkey.sh into a terminal nothing happens.

how to fix?

Thanks

P.S.
If under “/home/x245/appsJarPortable/” I run in Terminal

chmod +x searchMonkey.sh
./searchMonkey.sh

It works

Making the file executable is of course necessary.

If it’s a bash script I would recommend to give it the suffix .sh

This is obviously not part of your PATH variable, add it and it should work.

You could for example add the line

export PATH="${PATH}:/home/x245/appsJarPortable"

to the file ~/.bash_profile for local usage.

Or put the file in a directory being already part of your PATH variable. You can find out current status via

echo $PATH
3 Likes

~/.local/bin
(which likely is: /home/x245/.local/bin)
is already in your $PATH

Put the script there and you can call it by it’s name from everywhere.

or call it like:
/home/x245/appsJarPortable/searchMonkey.sh
(with the full PATH to it’s current location)

… the .sh prefix is just for you - you can call the script any name and it’ll work, no matter the prefix

1 Like

(Or extension.)

(Same.)

:stuck_out_tongue_winking_eye:

Thanks - I just made my coffee, but did not even have a sip yet…

So that’s your excuse. Actually a good one. I thought it’d be something like English isn’t my first language.

:stuck_out_tongue_winking_eye:

… and it is even true!

1 Like

*GASPS*

Absolutely shocking, I say! Makes it even better an excuse…

$ echo $PATH
/home/x245/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin

Let’s make thing clear, because I think there a misunderstanding:
My first goal was to make searchMonkey.sh executable by doubling clicking on it (file being in same folder as jar).
Then on success, I wanted to create a desktop icon which would launch it.

Under “/home/x245/”, I do have a file: “.bash_profile”
Content:

~/.bash_profile

[[ -f ~/.bashrc ]] && . ~/.bashrc

If I modify it as :

~/.bash_profile

export PATH=“${PATH}:/home/x245/appsJarPortable”
[[ -f ~/.bashrc ]] && . ~/.bashrc

Then I try double click on searchMonkey.sh nothing happens

In /home/x245/.local/, I only had “share” and “state” folders, so I create “bin” folder.

Put the script there and you can call it by it’s name from everywhere.

done, but nothing happens when double clicking on it.

or call it like:
/home/x245/appsJarPortable/searchMonkey.sh

??? but fwd slash is not a valid file name, what did you mean?

when I do:
echo $PATH
the result comes back starting with:
/home/nachlese/.local/bin: ....

Perhaps I made that work myself - I thought it was the default setting.

This is the full path to your script as you described where you created it

I’m thinking the best option would be to create a .desktop entry/file for it. See

https://wiki.archlinux.org/title/Desktop_entries#Application_entry

This is the full path to your script as you described where you created it

“call”: I thought you wanted me to rename the file as such(so my comment), now I understand you meant “execute in terminal”, aka run. Which works.

I’m thinking the best option would be to create a .desktop entry/file for it.
Works with “/home/x245/appsJarPortable/searchMonkey.sh”

Now, I do not understand why a double click directly on searchMonkey.sh is not working.

In /etc/profile.d/ there are some scripts
One of them is called: home-local-bin.sh
That is where the magic happens, where ~/.local/bin is included
this is what is in it:

case ":${PATH}:" in
  *:"$HOME/.local/bin":*) ;;
  *) export PATH="$HOME/.local/bin:$PATH" ;;
esac

because this location, this directory, is not in your PATH … probably
However, I don’t know - I never use the graphical file manager and mouse to do this

Please see this mini-guide → [root tip] [How To] I have downloaded a program as a jar file - what now?

4 Likes

Have you rebooted?

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.