This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Where should file path be? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Where should file path be?" Watch "Where should file path be?" New topic

Where should file path be?

Gulshan Singh
Ranch Hand

Joined: Apr 22, 2009
Posts: 41
I need to load a text file for my program. It only loads when its the absolute path, like C:\\file.txt. I want to make it so that it loads relative paths, so typing file.txt would load as long as its in the same directory as the program. I'm using Netbeans IDE and I tried putting file.txt by the classes and by the jar file, but it still can't locate the file when using a relative path. What should I do?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38040
Take it off NetBeans and execute it from the command line.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Where should file path be?
Similar Threads
java to read System environment variables!!!
jar location question
Issue in including image in a html from another server
where should I place my txt file on Tomcat 3.2.2
Application path problem