aspose file tools*
The moose likes Beginning Java and the fly likes Small .properties problem with multiple platform Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Small .properties problem with multiple platform" Watch "Small .properties problem with multiple platform" New topic
Author

Small .properties problem with multiple platform

Pablo Mino
Greenhorn

Joined: Aug 11, 2009
Posts: 28
Hi, I've seen this in a couple of post but can't get it to work

My problem is I got a .properties file which is read and written by a .jar app. When I run the project from eclipse I ge the file like this:



But the standard we work here says IF we use a .properties it should be in a /conf folder. so I change that line to this, everytime I require to build it with ant



Turns out that on Linux the "../" is nto working and I already trie all the combinations with // \\\ and anything

I would like in order to avoid the changes and the problems with relative paths, by including the .properties file inside the jar, something like keeping ti next to the src folder on eclipse and that when I build the Ant target it stays at the initial level inside the jar, How?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

When working with JAR files, you can't make any assumptions on what the current directory is, and therefore what relative files will be. Your resources should:
a) be specified using absolute paths, or
b) be put inside the JAR file so you can use Class.getResource(AsStream) or ClassLoader.getResource(AsStream), or
c) be put on the class path, so you can use ClassLoader.getResource(AsStream).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Pablo Mino
Greenhorn

Joined: Aug 11, 2009
Posts: 28
I choosed an option d), went for the preferences API, pretty cool thing

I'm using it to pass values between different JPanels as well, I wonder if I'm overusing it

Thanks for the help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Small .properties problem with multiple platform