Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31259 > unrolled thread

How do you set java to read properties in relative path ?

Started byAjay Paul <ajaykpaul@gmail.com>
First post2015-03-02 03:02 -0800
Last post2015-03-02 16:24 +0000
Articles 6 — 4 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  How do you set java to read properties in relative path ? Ajay Paul <ajaykpaul@gmail.com> - 2015-03-02 03:02 -0800
    Re: How do you set java to read properties in relative path ? Nigel Wade <nmw@ion.le.ac.uk> - 2015-03-02 12:39 +0000
    Re: How do you set java to read properties in relative path ? Nigel Wade <nmw@ion.le.ac.uk> - 2015-03-02 13:07 +0000
    Re: How do you set java to read properties in relative path ? Ajay Paul <ajaykpaul@gmail.com> - 2015-03-02 06:33 -0800
      Re: How do you set java to read properties in relative path ? Jeff Higgins <jeff@invalid.invalid> - 2015-03-02 10:57 -0500
    Re: How do you set java to read properties in relative path ? Robbie Brown <rob@example.com> - 2015-03-02 16:24 +0000

#31259 — How do you set java to read properties in relative path ?

FromAjay Paul <ajaykpaul@gmail.com>
Date2015-03-02 03:02 -0800
SubjectHow do you set java to read properties in relative path ?
Message-ID<3044c107-8eec-4c22-8954-83f1fce6bc6e@googlegroups.com>
How do you set java to read properties in relative path in local file system.

I can do it absolute path but not in relative path.

[toc] | [next] | [standalone]


#31260

FromNigel Wade <nmw@ion.le.ac.uk>
Date2015-03-02 12:39 +0000
Message-ID<clj3vbF54lgU1@mid.individual.net>
In reply to#31259
On 02/03/15 11:02, Ajay Paul wrote:
> How do you set java to read properties in relative path in local file system.
>
> I can do it absolute path but not in relative path.
>

There should be no difference between using a relative path and an absolute path, other than the obvious one.
Presumably your relative path is incorrect, or inaccessible for some other reason.

Without more information there really isn't much more help we can offer.

[toc] | [prev] | [next] | [standalone]


#31261

FromNigel Wade <nmw@ion.le.ac.uk>
Date2015-03-02 13:07 +0000
Message-ID<clj5kkF5jecU1@mid.individual.net>
In reply to#31259
On 02/03/15 11:02, Ajay Paul wrote:
> How do you set java to read properties in relative path in local file system.
>
> I can do it absolute path but not in relative path.
>

On the off chance that you mean "relative to the jar", rather than relative to your current location ( which is what a 
relative path is relative to), there was a thread about this a couple of weeks ago.

Search the archives for something to do with executable jars, and writing to files.

[toc] | [prev] | [next] | [standalone]


#31262

FromAjay Paul <ajaykpaul@gmail.com>
Date2015-03-02 06:33 -0800
Message-ID<def3e5c8-08e8-4bc3-bdeb-fd77eb7eca5a@googlegroups.com>
In reply to#31259
On Monday, 2 March 2015 16:33:58 UTC+5:30, Ajay Paul  wrote:
> How do you set java to read properties in relative path in local file system.
> 
> I can do it absolute path but not in relative path.

Dear All,

In eclipse:
I have placed my properties file in the same location as the class file. Just want to set a relative path in java to read the values from the properties file. But can't do that. I get the message:

Exception in thread "main" java.io.FileNotFoundException: .\Props.properties (The system cannot find the file specified)

It works fine when I add as an absolute path wrt the file system.

Is there a specific setting in the eclipse which needs to be configured/enabled to do that ?

[toc] | [prev] | [next] | [standalone]


#31264

FromJeff Higgins <jeff@invalid.invalid>
Date2015-03-02 10:57 -0500
Message-ID<md21i5$rqg$1@dont-email.me>
In reply to#31262
On 03/02/2015 09:33 AM, Ajay Paul wrote:
> On Monday, 2 March 2015 16:33:58 UTC+5:30, Ajay Paul  wrote:
>> How do you set java to read properties in relative path in local file system.
>>
>> I can do it absolute path but not in relative path.
>
> Dear All,
>
> In eclipse:
> I have placed my properties file in the same location as the class file. Just want to set a relative path in java to read the values from the properties file. But can't do that. I get the message:
>
> Exception in thread "main" java.io.FileNotFoundException: .\Props.properties (The system cannot find the file specified)
>
> It works fine when I add as an absolute path wrt the file system.
>
> Is there a specific setting in the eclipse which needs to be configured/enabled to do that ?
>
<http://stackoverflow.com/questions/2792870/java-cant-find-file-when-running-through-eclipse>

[toc] | [prev] | [next] | [standalone]


#31265

FromRobbie Brown <rob@example.com>
Date2015-03-02 16:24 +0000
Message-ID<md22qb$1vp$1@dont-email.me>
In reply to#31259
On 02/03/15 11:02, Ajay Paul wrote:
> How do you set java to read properties in relative path in local file system.
>
> I can do it absolute path but not in relative path.
>

Put the properties file in the same directory as the root of your 
binary(compiled) class hierarchy, by default, in Kepler it's bin.

So, in Navigator view you would have

myproject
myproject/bin
myproject/bin/props.properties
myproject/bin/com
myprojecy/bin/com/mycompany
...etc

works for me


-- 
Not floundering ... just fishing

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web