File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Small .properties problem with multiple platform" Watch "Small .properties problem with multiple platform" New topic

Small .properties problem with multiple platform

Pablo Mino

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

Joined: Oct 27, 2005
Posts: 20279

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).

How To Ask Questions How To Answer Questions
Pablo Mino

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:
subject: Small .properties problem with multiple platform
It's not a secret anymore!