• 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

Reading files within packages...

 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now that I have my application successfully broken out into packages, I have run into a small problem.
Before, when I had all my classes in the same directory and no packages, I also had in this directory a .properties file. Only on eclass needs access to this file, so when I created my packages I moved this file to the same package directory as the object that needs it.
When I try to run my application, I get an error saying that the file could not be found. What is the trick to proper file placement? I do not want to hard-code the address...
TIA
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried placing the file in the root directory of your package structure? I'm not sure if that will do the trick.
 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the idea Dirk, it made me try what actually worked...
I had to move it to the directory just above my package root (unless that is what you meant...)
Example:
java GUI class installed in C:\CAMRA2
my package structure is C:\CAMRA2\com\massappraisal\myPackages
I had to put the file in C:\CAMRA2, but it worked.
Thanks again,
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is what I meant, and I'm glad it works, because it makes sense that it could.
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic