Where does java look for files?

A relative path'ed file is looked for in the directory specified by System.getProperty("user.dir")


The answer is the working folder, which means the folder in which you executed the "java ..." command. This is the project folder in eclipse projects for instance.


Usually it's the exact location of where the Java file you are executing is. So if you use your Java file in C:\ and you look for a file without specifying a path, it will be in C:\ that it looks, and the output file will also be in C:\

If you are using something like Netbeans however, you just have to place the file in the netbeans project folder of your specific project (the root directory folder). Not in the source or bin folders of your project.

Tags:

Java

File