This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set the path so it works for all users!

 
Mouza Ali
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm developing a client in java under Kubuntu KDE4 OS. I would like to make it portable by running under any home environment. I mean, when the client creates files and documents under for example home//mouza//Documents, I would like it to be able to create those files under any home name like home//...//Documents. So I dont need to change in the java syntax each time I run it under a new machine!

How should I write the path in java? I wrote something like:
~//Documents , but it didn't work!

Any suggestions?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15437
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java has a system property named user.home, which gets the name of the home directory. The nice thing about it is that it's cross-platform - if you use this, it will also work on Windows.

[ December 12, 2008: Message edited by: Jesper Young ]
 
Mouza Ali
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Jesper, you really helped me
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic