• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File not found: "The system cannot find the file specified"

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to make some operations with a file. I struggle to understand why Apache is throwing this error:
(The system cannot find the file specified)

My file is located in the root directory of the project.

And here is how I indicate the path to it:



Thank you.

Update: If I put the file in the Eclipse folder, it works... But I need it to work if I put it in my project's root folder.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A path with only the file name ONLY works if the file is in the "current" directory.

Not something you should rely on for the server environment. Since the "current directory" is independent of your project root.

Bill
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,

Does the file in you classpath? If yes, you can try:



Best regards,
Felipe
 
Robert Insanovation White
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody, I resolved this by:



Thank you.
 
Felipe Rego Pinto
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Robert Insanovation White wrote:Hi everybody, I resolved this by:



Thank you.



This might also work.


 
Bartender
Posts: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The getRealPath() method, while useful, isn't your optimal solution here.
What happens when your app is deployed in a jar file? What is the filepath to it then?

If you are trying to load an image from your bundle, then the ServletContext method getResourceAsStream is probably more appropriate;
It is very similar to getRealPath in invoking. The main difference being instead of telling you the path to the resource, it just gives it straight to you.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic