Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Alternative to user.dir?

 
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...
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!