This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes How to set the path so it works for all users! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Reply Bookmark "How to set the path so it works for all users!" Watch "How to set the path so it works for all users!" New topic
Author

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

Mouza Ali
Ranch Hand

Joined: Oct 28, 2008
Posts: 39
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
Bartender

Joined: Aug 16, 2005
Posts: 12929
    
    3

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 ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Mouza Ali
Ranch Hand

Joined: Oct 28, 2008
Posts: 39
Thanks a lot Jesper, you really helped me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set the path so it works for all users!
 
Similar Threads
RMI from start to finish
deployment issue
Servlet Path/Path Info what for ?
weblogic.Admin command not running
install jdk cant find file