-2

I try to acces a file that i've placed on the src file using a relative path but in vain.

here is an example :
File file=new File("src/teledeclaration.xsd");

but i get the following error :

java.io.FileNotFoundException: /Users/macbookpro/Downloads/eclipse2
/Eclipse.app/Contents/MacOS/src/teledeclaration.xsd (No such file or directory)

why the below path appears before the normal path that i've written "src/teledeclation.xsd"

/Users/macbookpro/Downloads/eclipse2/Eclipse.app/Contents/MacOS/

how should i handle this problem ?

Zakaria Jaadi
  • 79
  • 1
  • 10
  • what is the directory structure of your project, and where is your project located on disk? I have a hard time believing that your project resides inside the Eclipse.app directory – Ben Glasser Sep 03 '15 at 22:35
  • @BenGlasser i have only one package "com.stage.service", src>com>stage>service , my class is on the service folder and i try to call the "teledeclaration" file that is placed directly on src and my project is located in [/Users/macbookpro/Documents/workspace/] – Zakaria Jaadi Sep 03 '15 at 22:45

1 Answers1

0

If you don't specify a full path, the path will be relative to your current working directory. If you check System.getProperty("user.dir") it should point to the Eclipse.app/... folder.

mvd
  • 2,596
  • 2
  • 33
  • 47