I have a directory structure of package/bin and package/lib, where package/lib contains jar files and package/bin should contain some scripts.
I am interested in writing scripts in package/bin that basically run java classes from lib/. These scripts should be runnable from any directory, not necessarily package/, package/bin/ or package/lib.
This means that the script in package/bin, let's call it 'run.sh' should do something like:
- identify the directory from which run.sh script is running.
- strip off the directory so that we end up with package/
- add bin/ to it
- run the necessary java classes with this deduced directory.
What would be the best way to follow steps 1-3? I would like it to be almost platform-independent, so that at the very least it would work on all Unix systems and OSX. I want to avoid using perl (I could easily write this in perl), and instead opt for a shell script.
Thanks.