This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Better way to determine current directory...

 
Bill White
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found that:
File currentDir = new File("");
does return the current directory that the JAR file is executing in.
Is this the best practice for doing something like this? I need to know at run time.
Thanks
 
David Weitzman
Ranch Hand
Posts: 1365
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably better to use

I believe the system property "user.dir" also works.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that technically, the meaning of "." is system-dependent. I know it means "current directory" on Unix and Windows, don't know about others. (Mac?) I use it often nonetheless, but it's probably better to use System.getProperty("user.dir") instead.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic