I'm working on an application in java that has a workDir string variable. This variable is dependent of the operating system and is the absolute path the the directory the application works out of. I've looked around and this is what I've come up with:
Windows x86 - C:\Program Files\
Windows x64 - C:\Program Files (x86)\
OS X - /Applications/
Unix based OSs - /opt/
If any of these directories are wrong, or there is a better directory to run from I would really appreciate the help. I myself run Windows, so I can't test any of the other folders.
as far as i know the Unix one is wrong.
The unix one should be as follow:
/usr/bin for userspace binaries
/bin for general binaries.
/sbin for System Binaries. (WARNING! this directory contains vital binaries like Init. messing with this could turn very bad)
As far as i know. Messing with either /bin and /sbin is a bit of a bad idea, hence why /usr/bin exists.
Also, look up the documentation for what type of UNIX OS you are using, For instance, BSD stores most of its binaries in /sbin, while Linux stores them in /bin. Be sure to look it up correctly because you definetly don't want to mess up something like a permission on either the /bin or /sbin directory. This could result in Kernel Panics or binaries simply refusing to start.
/opt seems to be for Add-on software... although i have rarely seen a populated /opt directory.
Thanks! I guess I'll use /usr/bin then.
EDIT: Can anybody confirm /Applications/ is the right folder on OS X?
Depending on your program, you will want to use one of these:
/usr/bin (user file that can sometimes be located on a network host)
/usr/sbin (user file for important binary programs for the shell [OS])
/usr/local (user file that is always located on the PC)
You'll want to use the file that best fits your program... For example, you may want to locate a video game to '/usr/local/' because games would not need to ever be run or stored on a network file, only locally.
However, your program may be something like an anti-virus, which could be run either locally on your own PC or on a network computer, so it should be stored in the usr/bin file.
Technically, most software should go to a "/usr/local/bin" file, but that is rarely ever the case...
So once again, this will depend on what your program is supposed to do.