File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 46375
Take it off NetBeans and execute it from the command line.
I agree. Here's the link:
subject: Where should file path be?
It's not a secret anymore!