My desire is not to change directory then execute. I use a jar file and need to execute that. So I made a very basic shell script to do that.
#!/bin/sh java -jar TreeForm.jar
Then, I saved it as
TreeForm.sh. Next, I created a symbolic link as below:
ln -s /opt/TreeForm/TreeForm /usr/bin/ chmod +x /opt/TreeForm/TreeForm
It is successfully created. However, when I run, I take the error below from JAVA.
Error: Unable to access jarfile TreeForm.jar
So, it seems shell script does not run its own directory or does not look into that, but works in current directory. I don't really want to modify my script file giving full path of
TreeForm.jar. So I wanted to ask, is there a way to find a file relative to script file without changing the current path or adding path to
PATH variable? Or is there any variable having the path of script, not the current one?