• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Loading a properties file in netbeans / forte

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using netbeans, and I'm trying to load a properties file. I tried placing the properties file in a few different places in the classpath, but nothing worked. Finally, I did the following within a unit test in netbeans:

and got this:
Why does it looking in the netbeans install directory? How do I get it to look in my project directory?
 
Lance Finney
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found my answer on their site:
Using the relative path to access a file
If you want to acces a file like
File file = new File("myfile.txt");
Netbeans/Forte looks for this file in the directory it is started from. To set the directory Netbeans/Forte searches for a file if its absolute path is not given, go to to the properties of your executor (right-click the class --> Properties --> Execution --> Executor), and on the Expert tab, set the "Working Directory" property to your desired directory.
This will work in Forte/Netbeans; however, it is generally not a good idea to access files in such a way. Instead, the contents of the file should be accessed like
InputStream in = MyClass.class.getResourceAsStream(RESOURCE_PATH);
 
reply
    Bookmark Topic Watch Topic
  • New Topic