Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

writing to jar file

 
Joe McIntyre
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm developing a desktop app in NetBeans. Currently, when I run the program from within the NetBeans environment, it uses (I think) the build folder, which does not have everything packaged in a jar file. So I can write to any of those folders that correspond to package names in my application. But what will happen when I package the whole thing in a jar file for deployment? I can't write to a file that is stored in that jar file can I? Is there a standard solution for this problem?

Thanks.
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Wally Flint:
I can't write to a file that is stored in that jar file can I?

No.

Originally posted by Wally Flint:

Is there a standard solution for this problem?

That depends on what you are trying to do.
 
Joe McIntyre
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, suppose I just want to save some application preferences... what would I do then?
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A good place to do that is in the user home directory.
You can get that through the java.lang.System.getProperties() method.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds like a case for the Preferences API.
 
Joe McIntyre
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic