• Post Reply Bookmark Topic Watch Topic
  • New Topic

System.getProperty(String)  RSS feed

 
D-bloK Chang
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I'm a little confused as to what the parameter being passed in would look like. I know it's a String, but it's a String "key" that is suppose to return some system property to me? I'm a little confused as to what this means. The reason i ask is because i'm looking through some code and it reads the following:

String seedFilename = System.getProperty("idp.seed.file");
I guess i'm not certain what the idp.seed.file is....it looks like a path of some sort? can someone explain this to me? Thanks in advance!
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thing you pass to getProperty() is the name of the property. The return string is the value of the property.

Properties can be established a couple of different ways for a running program.
]This tutorial came up for me in a google search; there are certainly others.
 
suresh koutam
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the String you are referring to be can be anything...mostly properties files.
For example....if you store your JSP mappings in a .props file...U can access these files from using the system coomands you are referring to. Mostly the properites or files that contain cinformation like jdbc connection info, jsp mappings and many other things that will be used in the main application. The main advantage of using these files is that you dont have to hard code the properites in your code ..it will be easy to change the props files instead of in the program.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by suresh koutam:
Actually the String you are referring to be can be anything...mostly properties files.
For example....if you store your JSP mappings in a .props file...U can access these files from using the system coomands you are referring to. Mostly the properites or files that contain cinformation like jdbc connection info, jsp mappings and many other things that will be used in the main application. The main advantage of using these files is that you dont have to hard code the properites in your code ..it will be easy to change the props files instead of in the program.


I don't think this is entirely true unless you first tell the JVM to load those files. By default the JVM defines a few properties. In general, the String passed to the getProperty() method can be anything. However, it is not useful unless the property is already defined somewhere. For example, you can get the list of default properties from the javadocs for the System class. Scroll down to the getProperties() method. The same list of properties are available through the getProperty() method that you are using.

HTH

Layne
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!