• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Better way to determine current directory...

 
Bill White
Ranch Hand
Posts: 82
  • 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
  • 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
  • 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