• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Reading and Writing Resources

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?

Posts: 43028
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic