MZimmerman6
MZimmerman6

Reputation: 8603

Java getAbsolutePath returning wrong path

This likely a very simple solution, but I can not seem to find the proper setting to adjust it. I have a file, lets say config.prop that needs to get read in by my application. It is at relative path ./someFolder/config.prop to my application. Whenever I try to get the absolute path of this, it returns a path that says it is in my eclipse folder, no my project.

String fileLocation = "./someFolder/config.prop"
File file = new File(fileLocation);
System.out.println(file.getAbsolutePath());

This will return C:\eclipse-mars\.\someFolder\config.prop where it really should return C:\my\project\path\someFolder\config.prop

I imagine this is some project setting that is super simple I am missing, but not sure where it may be in eclipse, I am not super familiar with eclipse.

Upvotes: 2

Views: 2214

Answers (1)

nitind
nitind

Reputation: 20003

The working directory can be set on your Java Application Launch Configuration's Arguments tab. You can open the Launch Configuration Dialog from the menu bar via Run->Run....

Upvotes: 3

Related Questions