• Post Reply Bookmark Topic Watch Topic
  • New Topic

finding current directory  RSS feed

 
Brian Coates
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to find out the directory that a class file is being ran in. The goal her is that someone could put my class file anywhere on their machine, and I could find the path of where that is.
I've checked the java.io.File methods, and it doesn't seem to have what I'm looking for.
Thanks.
 
Les Dsouza
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try
System.getProperty("user.dir")

hope this helps.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried it, but I think someone once recommended new File(".")...
DOM
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya it's new File(".").getName() gives u the current directory.U can use .getPath() to get the whole path also.
Happy middling with java.
Netharam
 
Brian Coates
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, i'll give that a try.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!