aspose file tools*
The moose likes I/O and Streams and the fly likes writing to jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "writing to jar file" Watch "writing to jar file" New topic
Author

writing to jar file

Joe McIntyre
Ranch Hand

Joined: Nov 20, 2003
Posts: 121
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

Joined: Oct 29, 2001
Posts: 8867
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Joe McIntyre
Ranch Hand

Joined: Nov 20, 2003
Posts: 121
Well, suppose I just want to save some application preferences... what would I do then?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8867
    
    8

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
Marshal

Joined: Mar 22, 2005
Posts: 41525
    
  53
That sounds like a case for the Preferences API.


Ping & DNS - my free Android networking tools app
Joe McIntyre
Ranch Hand

Joined: Nov 20, 2003
Posts: 121
Thanks guys!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: writing to jar file