You have only given the path for one directory or file. I was hoping that you would describe the WHOLE directory hierarchy for your project. Since you mentioned that you are using NetBeans 4.1, I think I can make some safe assumptions about this. I understand that your project lives in "D:\Titres de Film DVD". Since you are using NetBeans, there are probably the following directories under this:
nbproject - files for NetBeans to manage your projectsrc - this is probably where your source code (.java files) livestest - this is where any JUnit tests typically godist - this is where NetBeans will put the JAR file and Javadocs if you generate thembuild - this is where NetBeans will put generated class files Can you fill in any details that I may have missed here? Also please correct some assumptions.
So it sounds like you put the file.jpg image file under the build\classes\film_titles\Actors directory? This is a big HUGE mistake, especially if this is your master copy of that file. The build directory is TEMPORARY! If you accidentally tell NetBeans to clean your project, the build subdirectory will be deleted! Typically I create a directory called resources to store the master copy of such files.
Now to answer your question: First you need to get the user directory. To do this you just use the following line of code:
Any time you use a relative file path (i.e. one that doesn't start with C: or D: or whatever), it will be resolved relative to this user directory. For now, it will probably be simplest to put the Actors directory under this directory. You may want to write some test code that prints this out so you know what directory your program uses.
You should also learn about different types of paths that are used to locate files. This will include absolute paths and relative paths. Also make sure you understand the meaning of special directory names like . and .. since these come into play when you use relative paths.
Eventually, you may want to learn how to include these resource files in a JAR file and load them from there. To do so, you will need to look at the Class.getResource() and Class.getResourceAsStream() methods. This will make it easier to distribute your app since you will only need to distribute one JAR file rather than multiple image and class files.
You should also learn how to modify the build.xml file so that NetBeans can include the resources in the JAR file automatically. NetBeans uses a tool called
Ant that uses this build.xml file. Look for Ant documentation to find out more about making these modifications.
I hope this helps.
Regards,
Layne