Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: How to locate "suncerity.properties" in the current working directory?

 
Sang-Wook Kim
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am working on URLyBird and have a question about how to change
the path of the properties file. I have a class that handles the
properties in the suncertify.client package and I use "System.getProperty("user.dir")" function to get the path. The thing is that I have
to save the properties file in the current working directory, which
is 2 directories above suncertify/client directory. I was thinking
of doing like this:

I wrote "\\suncertify\\client", because I am sure that the ending
directory would like this. But I am not sure whether this would
also work on Linux. I belive it would work since the only difference
is that Linux uses "/" instead of "\". (Please correct me if I am
wrong) Is there a better way of doing this or would this be ok?
Kim
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kim, regarding properties file I think what they mean by it is this. Our application is sent as an executable jar to them. So no matter where they run the application, the application should create a properties file in that particular directory and use it. I think that is what they mean from this "properties file should be in the current working directory". This you can do in the way you said as getProperty("user.dir").
Good Luck.
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kim,
I confirm what Satish wrote above. System.getProperty("user.dir") returns the directory where the JVM was started. It can be or not the directory where your executable jar file resides, but it's what SUN means in our instructions by "current working directory".
Regards,
Phil.
 
Sang-Wook Kim
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish & Phil,
Hope I am getting it right. So System.getProperty("user.dir") gives
me the path of the directory in which I execute the program instead
of the path of the class which uses this function, because as Phil
wrote, System.getProperty("user.dir") returns the directory where the JVM was started. Am I correct?
Kim
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You/we are.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic