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

J

John_Woo

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.
 
S

Steve W. Jackson

"John_Woo said:
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
same value? -- it may be done by socket, rmi,..but it doesn't sound
good.

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 =
 
J

John_Woo

Steve said:
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 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.


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 =

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?
 
S

Steve W. Jackson

[ snip ]
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?

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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top