Results 1 to 9 of 9
Thread: [SOLVED] Getting directory paths
- 04-23-2008, 02:57 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 30
- Rep Power
- 0
[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.
- 04-23-2008, 03:04 AM #2
- 04-23-2008, 04:29 AM #3
Member
- Join Date
- Dec 2007
- Posts
- 30
- Rep Power
- 0
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 ;
- 04-23-2008, 05:07 AM #4
You should use:
System.out.println(System.getProperty("user.dir")) ;
- 04-23-2008, 05:16 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 04-23-2008, 05:22 AM #6
Member
- Join Date
- Dec 2007
- Posts
- 30
- Rep Power
- 0
Working now...
Thanks, that works.You should use:
System.out.println(System.getProperty("user.dir")) ;
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.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.
- 04-23-2008, 05:25 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 04-23-2008, 05:28 AM #8
Member
- Join Date
- Dec 2007
- Posts
- 30
- Rep Power
- 0
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.
- 04-23-2008, 05:30 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
It's up to you pal. :) If you have solved the question please mark it as SOLVED.
Best of luck for the exam. :)
Similar Threads
-
getting paths and directories
By marco in forum Java AppletsReplies: 3Last Post: 11-25-2007, 07:28 AM -
How can i get current directory?
By Ashley in forum New To JavaReplies: 1Last Post: 05-26-2007, 01:21 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks