I have developed a java application that i want to publish to my users. This application is an ancillary application used by many different shell scripts, such as sh, su, bash and zsh to name a few. My current approach is to put my program in /opt/myapp with a sh script to run the app.
#!/bin/bash
"$JAVA_HOME/bin/java" -jar /opt/myapp/myapp-1.0.jar $@
And I ask my users to add export PATH=$PATH:/opt/myapp
to their source such as ~/.zsrch
. However I keep having issues with some scripts or programs not finding the app bash: myapp: command not found
however it would work fine in /bin/su and /bin/zhc.
What is the right way to "install" my app on Linux and MacOS so that it is available across all shells.
The /opt/myapp folder
bash-3.2$ ls -l
total 40624
-rwxr-xr-x 1 root wheel 66 Apr 2 05:06 myapp
-rw-r--r-- 1 root wheel 20794374 Apr 2 05:05 myapp-1.0.jar
Path
bash-3.2$ echo $PATH
/opt/myapp:/Library/TeX/texbin::/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:~/.dotnet/tools:::/Users/accoun/bin
One of the examples is that an IntelliJ plugin runs the app to get information.
The plugin will run /bin/bash -c myapp version
as a process, however the output of that process is that bash: myapp: command not found
. However if i open a console the run bash it worked just fine.
~ » /bin/bash accoun@MACC02YX270LVDQ
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
bash-3.2$ echo $PATH
/opt/myapp:/Library/TeX/texbin::/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/share/dotnet:~/.dotnet/tools:::/Users/accoun/bin
bash-3.2$ myapp version
Myapp version 1.0
bash-3.2$
$PATH
is changed/extended, the change may affect only Bash and/or only interactive shells. Put a symlink in/usr/local/bin
and make sure that's in$PATH
for all users.