Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

where to have same user.home path or share same properties

Thread view: 
John_Woo - 21 Jul 2006 10:59 GMT
Hi,

if an app writes to a file, the location may be user.home, in Windowns
it is okay, but in unix, different user have different full-path.

I'm wondering, what's the idea to have unique full-path, which is
cross-platform? That way same app, event executed twice/more at the
same time in same machine, can share same file.

or, better idea to have same app run in different JVM <same machine>
share a properties, like System.getProperties("my app") always return
same value? -- it may be done by socket, rmi,..but it doesn't sound
good.

--
Thanks
John
Toronto
Steve W. Jackson - 21 Jul 2006 16:14 GMT
> Hi,
>
> if an app writes to a file, the location may be user.home, in Windowns
> it is okay, but in unix, different user have different full-path.

In Windows 98, every user's home directory is in the same location.  In
newer versions, each user account has a home directory of its own just
as in Unix (and they could be shared among users, as they also could in
Unix).

> I'm wondering, what's the idea to have unique full-path, which is
> cross-platform? That way same app, event executed twice/more at the
> same time in same machine, can share same file.

I suggest you check out the Java Preferences API as one possible
solution.  It allows user-level preferences or system-level preferences
to be created and maintained.  Where the information is stored for these
is system-dependent and transparent to your application.  In Windows,
it's typically in the Registry.  In the Linux system I've used, it's in
a user's .java/.userPrefs directory structure.  On Mac OS X, it's in a
PList file in the user's own ~/Library/Preferences directory.

> or, better idea to have same app run in different JVM <same machine>
> share a properties, like System.getProperties("my app") always return
[quoted text clipped - 5 lines]
> John
> Toronto

From the last part, I'm not quite clear on what it is you really want to
accomplish, so I can't offer much more than I have above.

= Steve =
Signature

Steve W. Jackson
Montgomery, Alabama

John_Woo - 21 Jul 2006 18:48 GMT
> > Hi,
> >
[quoted text clipped - 35 lines]
> Steve W. Jackson
> Montgomery, Alabama

Thanks Steve.

Can you tell how to make java app write an entry to  Registry <for
windows os>?

the last question was: any simple way for an app to set system
properties, and other app <event though same app, but running in other
folder> can get this properties?

--
John
Steve W. Jackson - 21 Jul 2006 19:30 GMT
[ snip ]

> Thanks Steve.
>
[quoted text clipped - 7 lines]
> --
> John

I gave you the clue to what I was suggesting in the earlier post, which
is the use of Preferences in Java (introduced in 1.4).

<http://java.sun.com/j2se/1.4.2/docs/api/java/util/prefs/Preferences.html

<http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html

You might use the static systemNodeForPackage method there, for example.  
If you have a class at com.acme.myclass, the system-level preference
node would be created for "com.acme".  On Windows, it happens that the
stored preference data would be in the Registry.  But that's not really
important.  What is important is that information can be placed there
once and then is accessible to other users in the same way to read it.

A warning is in order, though, if you want to use this for communication
between running applications.  It's not a good idea and may not work
reliably.

And Preferences may still not be the best solution for whatever problem
you're actually trying to solve, which you haven't actually said clearly
so far.
Signature

Steve W. Jackson
Montgomery, Alabama



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.