Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Alternative to user.dir?  RSS feed

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any other way to determine which hard drive that the user launched a java application from besides user.dir?
user.dir seems to be broken in the runtime I'm using.
Thanks,
Drew
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well user.dir is the one that's supposed to be guaranteed, so I'm wondering why it doesn't work. How are you calling it? What result do you get? As an alternative though, you can try something like
new File("").getAbsolutePath()
new File(".").getAbsolutePath()
new File("").getCanonicalPath()
new File(".").getCanonicalPath()
Interpretation of these paths ("" or ".") is OS-dependant, but I believe they should work to give you the current working directory on most Windows and Unix systems (no idea about Mac). Hope that helps...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!