Was reading some online tuts and best practices and it says do not save direct file to paths like this:
because when you distribute your programs the other person (rightfully) wont have the files in the same path.
ImageIcon imageBack = new ImageIcon("C:\\Users\\RyanFuji\\workspace\\Ryan\\src\\Capture.png");
Unfortunately it does not say HOW to do it instead.
Doing a search on google for paths and files as you can imagine gives me mostly class paths and java.io :rolleyes:
How to do this so it works everywhere?
save to the curent location of the program and to the curent user's home dir
While that makes sense, I'm a total newb and would appreciate some code to show me how that is done, please.
Originally Posted by dinosoep
Check the "user.home" property value in the System.getProperty( ... ) set of properties. It's a directory and you can construct a subdirectory from there where you can store and find your images.
Originally Posted by N00Bie
"user.home" often makes sense as has been noted previously.
Sometimes it makes sense for an application to save data to some specific location. This could be decided on by the user, or for multiple users it might have to be set by an administrator who can assign the appropriate rights etc. Moreover the data location is just a special case of general properties that may need to be set which could be anything: locale, default font size etc.
For tools that help with the general case, have a read of The Platform Environment in Oracle's Tutorial. System properties can also be set when the program is launched using the -D option of the java executable.
Thanks guys! Am off to Google based on your help... feel free to leave additional advise if you want.