The problem
When executing a application it is not uncommon that you need to be in that applications base directory so it can find its resource files. This is especially true when it comes to Java based applications and games on the Linux platform.
Some times this is just stated in the installations instructions and you have to change into the base directory before executing the binary that starts the application. My (not so humble) opinion is that this is not a acceptable solution. Mainly since I like to have a link to the application in a common directory such as /usr/local/bin/_ so I don’t have to change my PATH. Also I want to be able to start my applications from anywhere.
Simple and common solution
A simple and common solution for this is to create a shell script that gets the directory portion of the command executed and then switches into that directory before launching the application.
|
|
The problem with this solution is that if you put this script (or a link to this script) in you PATH and then call it whitout the absolut path it will not find the correct basedir.
A better solution
|
|
If you put this script into the application base directory and then create a symbolic link in /usr/local/bin you can now start the application from anywhere just by executing app (provided this is the name of the shellscript).