How to get the userdir of your NetBeans RCP application?

Userdir is a directory where NetBeans RCP applications store settings and cache. Sometimes it can be helpful to be able to get the directory from the NetBeans RCP application itself. Most of the users initially go with something like:

String user_dir = System.getProperty("user.dir");

... and then they realize this returns a different folder from what they need. Instead, they are looking for this:

String user_dir = System.getProperty("netbeans.user");

Comments:

Probably preferable to use InstalledFileLocator, which should search both the NetBeans install (i.e. all cluster dirs, wherever they are on disk including the Extra cluster).

Most times a module should be writing underneath their cluster, not directly into the root of the userdir (though there are certain exceptions, such as writing a file that indicates the user has agreed to a particular license, etc.)

Posted by Tim Boudreau on July 09, 2009 at 04:14 AM PDT #

Thank you so much for this great article it's so useful

Posted by mkv converter on July 14, 2009 at 12:46 AM PDT #

Thank you for the clarifying comment, Tim. Yes, in many circumstances it is better (cleaner) to use InstalledFileLocator... I believe the property might be helpful too though in many cases...

Posted by Petr Dvorak on July 14, 2009 at 10:35 PM PDT #

Post a Comment:
Comments are closed for this entry.
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today