Results 1 to 9 of 9
  1. #1
    Leprechaun is offline Member
    Join Date
    Dec 2007
    Posts
    30
    Rep Power
    0

    Default [SOLVED] Getting directory paths

    Lots of computers have there main hardrive named C but some don't. Also, some users don't have the same My Pictures directory or Program Files directory. I was wondering if it's possible to find out what those paths are in order to make my programs more user friendly. I know the data is in the registry somewhere but I have no experience with getting that info with Java.
    Last edited by Leprechaun; 04-23-2008 at 05:31 AM.

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    dont worry newbie, we got you covered.

  3. #3
    Leprechaun is offline Member
    Join Date
    Dec 2007
    Posts
    30
    Rep Power
    0

    Default

    Those look like what I need. However, I'm pretty new to java and am having problems using them.
    For example, I tried
    System.out.println(user.dir);
    but I got an error. I don't know if I need to import something, and if so I'm not sure what.
    Last edited by Leprechaun; 04-23-2008 at 04:30 AM. Reason: Added ;

  4. #4
    rpwtdj's Avatar
    rpwtdj is offline Member
    Join Date
    Dec 2007
    Posts
    15
    Rep Power
    0

    Default

    You should use:
    System.out.println(System.getProperty("user.dir")) ;

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Leprechaun, I think you worked on a Java IDE. Because almost all IDEs prompt that error. You can get an idea why it is wrong just looking at the error message.

  6. #6
    Leprechaun is offline Member
    Join Date
    Dec 2007
    Posts
    30
    Rep Power
    0

    Default Working now...

    You should use:
    System.out.println(System.getProperty("user.dir")) ;
    Thanks, that works.

    Leprechaun, I think you worked on a Java IDE. Because almost all IDEs prompt that error. You can get an idea why it is wrong just looking at the error message.
    I did see that but didn't know what to do. It said it didn't recognize the symbol which is why I thought I might need to import something. I'll be sure to always check that before posting errors I can't solve in my code.

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by Leprechaun View Post
    I did see that but didn't know what to do. It said it didn't recognize the symbol which is why I thought I might need to import something. I'll be sure to always check that before posting errors I can't solve in my code.
    No anytime you can post your questions here. What I try to say is, those error message really helpful for Java newbie. I don't know how far JCreator(you are working on that, right?) descriptive with error messages. In Netbeans, Eclipse it is nice. :)

  8. #8
    Leprechaun is offline Member
    Join Date
    Dec 2007
    Posts
    30
    Rep Power
    0

    Default

    I think JCreator (you were right) does pretty good as far as displaying errors. It lists the errors, what line numbers there on and what the error is. Once I have more free time (4 AP Exams coming up for those who know what that means) I'll probably try different IDE's and play around more with Java in general.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. getting paths and directories
    By marco in forum Java Applets
    Replies: 3
    Last Post: 11-25-2007, 07:28 AM
  2. How can i get current directory?
    By Ashley in forum New To Java
    Replies: 1
    Last Post: 05-26-2007, 01:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •