Hi all!I wish to save some user data (editable via GUI) on a per user basis.Is there any nice mechanism in Java that puts such info into anappropriate place? If I have to do that manually, what would be a niceplace to save some small files with bothering the user? Or shall Iforce every user to specify a directory?Karsten
|
|
0
|
|
|
|
Reply
|
kwutzke (87)
|
4/18/2007 5:07:00 PM |
|
Karsten Wutzke wrote:> Hi all!> > I wish to save some user data (editable via GUI) on a per user basis.> > Is there any nice mechanism in Java that puts such info into an> appropriate place? If I have to do that manually, what would be a nice> place to save some small files with bothering the user? Or shall I> force every user to specify a directory?> > Karsten> Look at the system property user.home.-- Knute Johnsonemail s/nospam/knute/
|
|
0
|
|
|
|
Reply
|
Knute
|
4/18/2007 5:19:27 PM
|
|
On 18 Apr., 19:19, Knute Johnson <nos...@rabbitbrush.frazmtn.com>wrote:> Karsten Wutzke wrote:> > Hi all!>> > I wish to save some user data (editable via GUI) on a per user basis.>> > Is there any nice mechanism in Java that puts such info into an> > appropriate place? If I have to do that manually, what would be a nice> > place to save some small files with bothering the user? Or shall I> > force every user to specify a directory?>> > Karsten>> Look at the system property user.home.>> -->> Knute Johnson> email s/nospam/knute/I know this. But I don't want to create files or directories "unasked"which will clutter the user's home dir and make some users really mad(as I would be).Karsten
|
|
0
|
|
|
|
Reply
|
Karsten
|
4/18/2007 5:36:06 PM
|
|
Karsten Wutzke schrieb:
> I wish to save some user data (editable via GUI) on a per user basis.
>
> Is there any nice mechanism in Java that puts such info into an
> appropriate place? If I have to do that manually, what would be a nice
> place to save some small files with bothering the user? Or shall I
> force every user to specify a directory?
Sounds like you need java.util.prefs.Preferences.
You can get a handle to the user's preferences by:
Preferences prefs =
Preferences.userNodeForPackage(my.package.Main.class);
Java keeps the user's preferences in a platform-specific place:
(*) for Windows: in a certain user-specific branch of the registry
(*) for Unix/Linux: in a certain hidden file in the user's home dir.
But you don't have to care about those details.
You read/write specific key/value like this:
String value = prefs.get(key);
prefs.get(key, value);
For more details see the API docs
<http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>
<http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html#userNodeForPackage(java.lang.Class)>
--
Thomas
|
|
0
|
|
|
|
Reply
|
Thomas
|
4/18/2007 5:36:52 PM
|
|
On Apr 18, 1:36 pm, Thomas Fritsch <i.dont.like.s...@invalid.com>wrote:> Karsten Wutzke schrieb:>> > I wish to save some user data (editable via GUI) on a per user basis.>> > Is there any nice mechanism in Java that puts such info into an> > appropriate place? If I have to do that manually, what would be a nice> > place to save some small files with bothering the user? Or shall I> > force every user to specify a directory?>> Sounds like you need java.util.prefs.Preferences.>> You can get a handle to the user's preferences by:> Preferences prefs => Preferences.userNodeForPackage(my.package.Main.class);> Java keeps the user's preferences in a platform-specific place:> (*) for Windows: in a certain user-specific branch of the registry> (*) for Unix/Linux: in a certain hidden file in the user's home dir.> But you don't have to care about those details.>> You read/write specific key/value like this:> String value = prefs.get(key);> prefs.get(key, value);>> For more details see the API docs> <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>> <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.h...)>>> --> ThomasThere wouldn't be any problem with permissions using this method,would there? (AKA - The user can't write to the registry.)
|
|
0
|
|
|
|
Reply
|
Jason
|
4/18/2007 9:36:47 PM
|
|
On Apr 18, 2:36 pm, Jason Cavett <jason.cav...@gmail.com> wrote:> On Apr 18, 1:36 pm, Thomas Fritsch <i.dont.like.s...@invalid.com> wrote:> > Sounds like you need java.util.prefs.Preferences.> >> > You can get a handle to the user's preferences by:> > Preferences prefs => > Preferences.userNodeForPackage(my.package.Main.class);> > Java keeps the user's preferences in a platform-specific place:> > (*) for Windows: in a certain user-specific branch of the registry> > (*) for Unix/Linux: in a certain hidden file in the user's home dir.> > But you don't have to care about those details.>> > You read/write specific key/value like this:> > String value = prefs.get(key);> > prefs.get(key, value);>> > For more details see the API docs> > <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>> > <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.h...)>>> There wouldn't be any problem with permissions using this method,> would there? (AKA - The user can't write to the registry.)The default Sun implementation on Windows stores preferences in a nodeunder HKEY_CURRENT_USER, which is always writable by the current userand is normally made part of the user's profile, whether local orroaming.So no, not really.
|
|
0
|
|
|
|
Reply
|
angrybaldguy
|
4/18/2007 9:53:38 PM
|
|
Karsten Wutzke wrote:> On 18 Apr., 19:19, Knute Johnson <nos...@rabbitbrush.frazmtn.com>> wrote:>> Karsten Wutzke wrote:>>> Hi all!>>> I wish to save some user data (editable via GUI) on a per user basis.>>> Is there any nice mechanism in Java that puts such info into an>>> appropriate place? If I have to do that manually, what would be a nice>>> place to save some small files with bothering the user? Or shall I>>> force every user to specify a directory?>>> Karsten>> Look at the system property user.home.>>>> -->>>> Knute Johnson>> email s/nospam/knute/> > I know this. But I don't want to create files or directories "unasked"> which will clutter the user's home dir and make some users really mad> (as I would be).> > Karsten> Then store it on a remote server. I really don't think that makes any sense but it accomplishes what you want; a file but not on the users computer.When I look in my Windoze computer home directory I can find 25 folders of stuff that applications have put there. That is where that kind of stuff belongs. I didn't look at my Linux home directory but I know there is a lot of application data there too.-- Knute Johnsonemail s/nospam/knute/
|
|
0
|
|
|
|
Reply
|
Knute
|
4/18/2007 10:28:38 PM
|
|
Thomas Fritsch wrote:> Karsten Wutzke schrieb:>> I wish to save some user data (editable via GUI) on a per user basis.>>>> Is there any nice mechanism in Java that puts such info into an>> appropriate place? If I have to do that manually, what would be a nice>> place to save some small files with bothering the user? Or shall I>> force every user to specify a directory?> > Sounds like you need java.util.prefs.Preferences.> > You can get a handle to the user's preferences by:> Preferences prefs => Preferences.userNodeForPackage(my.package.Main.class);> Java keeps the user's preferences in a platform-specific place:> (*) for Windows: in a certain user-specific branch of the registry> (*) for Unix/Linux: in a certain hidden file in the user's home dir.> But you don't have to care about those details.> > You read/write specific key/value like this:> String value = prefs.get(key);> prefs.get(key, value);> > For more details see the API docs> <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>> <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html#userNodeForPackage(java.lang.Class)> > > I hadn't seen this before (where have I been?). Where does it store stuff on a Linux system?-- Knute Johnsonemail s/nospam/knute/
|
|
0
|
|
|
|
Reply
|
Knute
|
4/18/2007 10:31:44 PM
|
|
On Apr 18, 5:53 pm, angrybald...@gmail.com wrote:> On Apr 18, 2:36 pm, Jason Cavett <jason.cav...@gmail.com> wrote:>>>> > On Apr 18, 1:36 pm, Thomas Fritsch <i.dont.like.s...@invalid.com> wrote:> > > Sounds like you need java.util.prefs.Preferences.>> > > You can get a handle to the user's preferences by:> > > Preferences prefs => > > Preferences.userNodeForPackage(my.package.Main.class);> > > Java keeps the user's preferences in a platform-specific place:> > > (*) for Windows: in a certain user-specific branch of the registry> > > (*) for Unix/Linux: in a certain hidden file in the user's home dir.> > > But you don't have to care about those details.>> > > You read/write specific key/value like this:> > > String value = prefs.get(key);> > > prefs.get(key, value);>> > > For more details see the API docs> > > <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>> > > <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.h...)>>> > There wouldn't be any problem with permissions using this method,> > would there? (AKA - The user can't write to the registry.)>> The default Sun implementation on Windows stores preferences in a node> under HKEY_CURRENT_USER, which is always writable by the current user> and is normally made part of the user's profile, whether local or> roaming.>> So no, not really.By "normally" do you mean that, assuming no problems, I can assume thesettings will be saved on a per-user basis?
|
|
0
|
|
|
|
Reply
|
Jason
|
4/19/2007 3:44:05 AM
|
|
Knute Johnson wrote:> Thomas Fritsch wrote:>> >> Preferences prefs =>> Preferences.userNodeForPackage(my.package.Main.class);>> Java keeps the user's preferences in a platform-specific place:>> (*) for Windows: in a certain user-specific branch of the registry>> (*) for Unix/Linux: in a certain hidden file in the user's home dir.>> But you don't have to care about those details.> > I hadn't seen this before (where have I been?). Where does it store > stuff on a Linux system?> On my Linux I found it in file $HOME/.java/.userprefs/my/package/prefs.xmlAnd (by the way) on Windows it is in registry section HKEY_CURRENT_USER\Software\JavaSoft\prefs\my\package-- Thomas
|
|
0
|
|
|
|
Reply
|
Thomas
|
4/19/2007 10:03:10 AM
|
|
Thomas Fritsch wrote:> On my Linux I found it in file> $HOME/.java/.userprefs/my/package/prefs.xml $HOME/.java/.userPrefs/my/package/prefs.xml> > And (by the way) on Windows it is in registry section> HKEY_CURRENT_USER\Software\JavaSoft\prefs\my\package HKEY_CURRENT_USER\Software\JavaSoft\Prefs\my\packageSorry for the 2 typos...-- Thomas
|
|
0
|
|
|
|
Reply
|
Thomas
|
4/19/2007 1:18:12 PM
|
|
Thomas Fritsch wrote:> Thomas Fritsch wrote:>> On my Linux I found it in file>> $HOME/.java/.userprefs/my/package/prefs.xml> $HOME/.java/.userPrefs/my/package/prefs.xml>>>> And (by the way) on Windows it is in registry section>> HKEY_CURRENT_USER\Software\JavaSoft\prefs\my\package> HKEY_CURRENT_USER\Software\JavaSoft\Prefs\my\package> > Sorry for the 2 typos...> Thanks Thomas.-- Knute Johnsonemail s/nospam/knute/
|
|
0
|
|
|
|
Reply
|
Knute
|
4/19/2007 4:46:28 PM
|
|
Jason Cavett wrote:> On Apr 18, 5:53 pm, angrybald...@gmail.com wrote:>> On Apr 18, 2:36 pm, Jason Cavett <jason.cav...@gmail.com> wrote:>>>>>>>>> On Apr 18, 1:36 pm, Thomas Fritsch <i.dont.like.s...@invalid.com> wrote:>>>> Sounds like you need java.util.prefs.Preferences.>>>> You can get a handle to the user's preferences by:>>>> Preferences prefs =>>>> Preferences.userNodeForPackage(my.package.Main.class);>>>> Java keeps the user's preferences in a platform-specific place:>>>> (*) for Windows: in a certain user-specific branch of the registry>>>> (*) for Unix/Linux: in a certain hidden file in the user's home dir.>>>> But you don't have to care about those details.>>>> You read/write specific key/value like this:>>>> String value = prefs.get(key);>>>> prefs.get(key, value);>>>> For more details see the API docs>>>> <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>>>>> <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.h...)>>>> There wouldn't be any problem with permissions using this method,>>> would there? (AKA - The user can't write to the registry.)>> The default Sun implementation on Windows stores preferences in a node>> under HKEY_CURRENT_USER, which is always writable by the current user>> and is normally made part of the user's profile, whether local or>> roaming.>>>> So no, not really.> > By "normally" do you mean that, assuming no problems, I can assume the> settings will be saved on a per-user basis?> Yes because for one thing the registry hive where the data is accessible for the current user is HKEY_CURRENT_USER (imagine that) so it would have to be on a per user basis because there is only one current user allowed with Windows XP. Plus, if you look into HKEY_USERS hive in the registry it will list all the SIDs of the users who have logged into the PC whose registry you are currently viewing. A user's registry data is part of the users profile so it will follow them (stored in ntuser.dat in every user's profile) and when they log in the HKEY_CURRENT_USER hive is just a link to the real location under HKEY_USERS. It is possible for permissions to be screwed up on HKEY_CURRENT_USER such that a user can't retain settings (like Windows Explorer folder view preferences) but normally each user can read/write to that location because they need to.I use the Preferences API in my program to store connection settings to a remote server in the registry for each other based on a recommendation I received from this group a few months ago. The API is so easy and after I experimented with it I was able to implement my code very quickly.
|
|
0
|
|
|
|
Reply
|
Brandon
|
4/20/2007 12:36:23 AM
|
|
On Apr 19, 8:36 pm, Brandon McCombs <n...@none.com> wrote:
> Jason Cavett wrote:
> > On Apr 18, 5:53 pm, angrybald...@gmail.com wrote:
> >> On Apr 18, 2:36 pm, Jason Cavett <jason.cav...@gmail.com> wrote:
>
> >>> On Apr 18, 1:36 pm, Thomas Fritsch <i.dont.like.s...@invalid.com> wrote:
> >>>> Sounds like you need java.util.prefs.Preferences.
> >>>> You can get a handle to the user's preferences by:
> >>>> Preferences prefs =
> >>>> Preferences.userNodeForPackage(my.package.Main.class);
> >>>> Java keeps the user's preferences in a platform-specific place:
> >>>> (*) for Windows: in a certain user-specific branch of the registry
> >>>> (*) for Unix/Linux: in a certain hidden file in the user's home dir.
> >>>> But you don't have to care about those details.
> >>>> You read/write specific key/value like this:
> >>>> String value = prefs.get(key);
> >>>> prefs.get(key, value);
> >>>> For more details see the API docs
> >>>> <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>
> >>>> <http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.h...)>
> >>> There wouldn't be any problem with permissions using this method,
> >>> would there? (AKA - The user can't write to the registry.)
> >> The default Sun implementation on Windows stores preferences in a node
> >> under HKEY_CURRENT_USER, which is always writable by the current user
> >> and is normally made part of the user's profile, whether local or
> >> roaming.
>
> >> So no, not really.
>
> > By "normally" do you mean that, assuming no problems, I can assume the
> > settings will be saved on a per-user basis?
>
> Yes because for one thing the registry hive where the data is accessible
> for the current user is HKEY_CURRENT_USER (imagine that) so it would
> have to be on a per user basis because there is only one current user
> allowed with Windows XP. Plus, if you look into HKEY_USERS hive in the
> registry it will list all the SIDs of the users who have logged into the
> PC whose registry you are currently viewing. A user's registry data is
> part of the users profile so it will follow them (stored in ntuser.dat
> in every user's profile) and when they log in the HKEY_CURRENT_USER hive
> is just a link to the real location under HKEY_USERS. It is possible
> for permissions to be screwed up on HKEY_CURRENT_USER such that a user
> can't retain settings (like Windows Explorer folder view preferences)
> but normally each user can read/write to that location because they need
> to.
>
> I use the Preferences API in my program to store connection settings to
> a remote server in the registry for each other based on a recommendation
> I received from this group a few months ago. The API is so easy and
> after I experimented with it I was able to implement my code very quickly.- Hide quoted text -
>
> - Show quoted text -
I just finished implementing Preferences for an application I'm
working on. Wow...haha...that was so painless I felt like I did
something wrong.
;-) Loving the Preferences.
|
|
0
|
|
|
|
Reply
|
Jason
|
4/20/2007 4:20:20 PM
|
|
|
13 Replies
94 Views
(page loaded in 0.126 seconds)
Similiar Articles: Safari won't save User ID and Password - comp.sys.mac.apps ...I'm having a small ... Re: Why safari won't ask to save certain user/password? ... user name and password, Safari will ask if you want it to save that information for ... Saving/Loading The Workspace From a Structure Within .mat - comp ...I would like to also save the current iterative data to this file. What I ... currentData.m with the structure saved by the user in user.mat (t). I am only to load/save ... Save image as tif by using imwrite - comp.soft-sys.matlab ...I thought it is very simple but I'm really stuck. I want to save in TIF format the image edited by user in GUI. I have the original data array (dou... Fastest way to save data? - comp.soft-sys.matlabfastest way to copy a disk - comp.unix.solaris Fastest way to save data? - comp.soft-sys.matlab fastest way to copy a disk - comp.unix.solaris Fastest way to save data ... Matlab Engine and Control - comp.soft-sys.matlab... run it, and it should call the matlab controller design routine where the user will decide for the best controller, and then the user should save the controller data (e ... Save as .pdf in Windows? - comp.databases.filemakerHi -- I'm a happy Mac-platform Filemaker user trying to help out a local museum with using their filemaker database for some further functions tha... JTable Problem - values not set when clicked on button - comp.lang ...Hi. I have a frame with a table in it and when the user enters values into it they are able to save the table. However if the user doesn't press enter... DBWorks or Agile - comp.cad.solidworksIt could save a day or two. 6) JDE could extract data to help minimize user input on that level. Thanks again for everone's advice and willingness to help. JTable, edit a cell, but changed value not seen - comp.lang.java ...I have an issue where the last cell in a selected row is edited and then the user selects the "Update" button to save the changes. The Update button is coded to grab data ... Populate form-fillable pdf from command line - comp.text.pdf ...... data into the format(s) you wish to support, e.g., FDF, XFDF, and then return the formatted form data to the client-side browser to allow the user to save the form data ... Can one save a filled out PDF form with completed data - comp.text ...I simply wish to save my filled out form as a pdf file. Is this possible? Thank You Lisa ... save to specified folder - comp.soft-sys.matlab> > Max Assume the variable is called Data in your workspace save('c:\yourfolder\Data.mat ... And call uigetdir() if you want your user to select the folder where the ... How to Save Records with Only Buttons I create, and prevent ...Save record ONLY when button clicked - Tech Support Guy Forums Please refer to the attached ... user think they are saving a NEW record only to ... and set it to "Current ... Lookup: Howto display one field and store the value of another ...I want to have a text field with a popup, where all suppliers are displayed and the user can choose one, but in the record I want to save the corresponding SupplierID. GUI to record , stop, playback sound - comp.soft-sys.matlab ...... reserved - to be defined in a future version of MATLAB > % handles structure with handles and user data (see GUIDATA) > play(myVoice); You have to save and ... Save user data - Microsoft Corporation: Software, Smartphones ...I'm certain that my relative inexperience with .net will become apparent with this question, but here goes. 1. What is the best way to persist user data ... Automatically Saving Web Form Data - CodeProjectHow to automatically save user input in web applications.; Author: Usman Shaheen; Updated: 25 Sep 2006; Section: ASP.NET; Chapter: Web Development; Updated: 25 Sep 2006 7/27/2012 3:14:29 PM
|