aspose file tools*
The moose likes Beginning Java and the fly likes Question about System.getProperties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about System.getProperties" Watch "Question about System.getProperties" New topic
Author

Question about System.getProperties

George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Hello everyone,


I am wondering where does the properties retrieved from System.getProperties defined, in some system level environment variables, some files or some other repositories. I am also wondering if I retrieved a specific property from System.getProperties, could I find out where it is defined (system level environment variable, some files or some other repositories).


Thanks in advance,
George
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
From my understanding, the JVM generates some of the values itself, such as the vendor and version number. The OS-specific values are retrieved from the operating, probably with a native method that calls some function in the OS's API. This means that the location where the value is stored is system dependent. AFAIK, Java does not provide any way to determine the location where the values are stored.

Is this just an academic question, or do you need to know the location for some reason?

Layne


Java API Documentation
The Java Tutorial
George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Thanks Layne,


Originally posted by Layne Lund:
From my understanding, the JVM generates some of the values itself, such as the vendor and version number. The OS-specific values are retrieved from the operating, probably with a native method that calls some function in the OS's API. This means that the location where the value is stored is system dependent. AFAIK, Java does not provide any way to determine the location where the values are stored.

Is this just an academic question, or do you need to know the location for some reason?

Layne


Your reply is very helpful. I am very interested in the internal operations of where to find these properties and in what sequence are they loaded (for example, loading OS defined properties before loading VM specific properties). Do you know where can I find any online resources dealing this topic?


regards,
George
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
I suppose if you really need to know you could define properties in your environment and on the java command line (-Dfoo=bar) that you know the JVM will overwrite to see which one wins over the others.

I must assume it sets its internal properties first, so the real question is which first: environment or arguments?

As to which come from where, I bet most of the JVM ones are defined in the System class JavaDocs or should be obvious from inspection. Your environment variables are available to you with the set command. But as Layne said I doubt there's a way to do this dynamically.
George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Thanks David,


Originally posted by David Harkness:
I suppose if you really need to know you could define properties in your environment and on the java command line (-Dfoo=bar) that you know the JVM will overwrite to see which one wins over the others.

I must assume it sets its internal properties first, so the real question is which first: environment or arguments?

As to which come from where, I bet most of the JVM ones are defined in the System class JavaDocs or should be obvious from inspection. Your environment variables are available to you with the set command. But as Layne said I doubt there's a way to do this dynamically.


Your reply is very helpful. Maybe I have not made myself understood. I do not want to know how to define a property. I want to know the internal operations of where does VM find these properties and in what sequence are they loaded (for example, loading OS defined properties before loading VM command line specific properties). Do you know where can I find any online resources dealing this topic?


regards,
George
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by George Lin:
I want to know the internal operations of where does VM find these properties and in what sequence are they loaded (for example, loading OS defined properties before loading VM command line specific properties).
That's precisely what my reply was designed to test. If you want to know which is done first, system vs. command line properties, here's what you do.
  • set system property PROP_TEST to "system"
  • run java program to dump out PROP_TEST value with command-line property PROP_TEST set to "cli"
  • PROP_TEST's value should tell you which takes precedence (is assigned last)

  • Yes, I'm sure you can look this up somewhere; what Google queries have you tried so far?
    George Lin
    Ranch Hand

    Joined: Jan 11, 2005
    Posts: 125
    Thanks David,


    Originally posted by David Harkness:
    That's precisely what my reply was designed to test. If you want to know which is done first, system vs. command line properties, here's what you do.
  • set system property PROP_TEST to "system"
  • run java program to dump out PROP_TEST value with command-line property PROP_TEST set to "cli"
  • PROP_TEST's value should tell you which takes precedence (is assigned last)

  • Yes, I'm sure you can look this up somewhere; what Google queries have you tried so far?


    Your reply is very helpful. I am wondering what key words should I use to do a Google search. Google tells me many API descriptions other than the internal operations (for example, sequence to find properties), which I am really interested in.


    regards,
    George
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Question about System.getProperties
     
    Similar Threads
    Can you retrieve from SourceSafe on a Unix box?
    EMSRV not starting
    adapting content for wireless web services
    Central repository for OSGi bundles
    Should I install J2EE on Client side?