• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Reading and Writing Resources  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I am relatively new to java in general. I have a frustrating problem to which I can't seem to find a working solution:

I work in NetBeans. My application manages user profiles and in doing so it generates (renders) picture files (avatars) which it has to save (as bmp) for each user and load again when each user logs in.
In NetBeans, everything works fine with the getClass().getResource("/path/to/image.bmp) statement which returns a URL and path to the file or directory at runtime.

How do I go about when distributing the application? I can't use the getResource in the jar file because I need to write to the directory when the images need to be updated and jar's are read-only. My database (an mdb file using access driver) is also in a resource directory that needs to be read/writable.
I suppose I should take these dynamic resources out of the jar and put it in some external Library folder upon installation. But how do I get the absolute path to this directory at runtime to access the files? The getCodeSource().getLocation() only works inside the jar itself. In short, how do I make the application portable while still being able to access these dynamic resources (image directory and database file)? Is there a more elegant to access dynamic resources at runtime?

Thanks
 
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this application run on multiple desktops or just one? Where are the images generated, and do those need to be available to all users of the application (if there are several), or just the one user who created the images?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!