Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Get Property by Name 
 

In this Tutorial we want to describe you a code that helps you in understanding to get Property by Name. For this we have a class name "Get Property By Name".

 

Get Property by Name

                         

In this Tutorial we want to describe you a code that helps you in understanding to get Property by Name. For this we have a class name "Get Property By Name". Inside the main method  we have the list of method that help you to get the Properties of  System-

1)System.getProperties ( ) -  This Method returns you current system properties by assigning an instance of properties class and store the current system properties in it.

2)stringPropertyNames( ) -   This Method returns you the current system properties in a Set object  set (Collection interface).

3)Iterator ( )                     -   This allow you to traverse the list of element in a collection.

We declare a String variable name key inside the main method followed by while loop, that  is used to evaluate or check more element present in a iterator .If more element is present, the iterator call next( ).to string returns you the next element in the iterator, convert it into a string and store in a String variable key. The System.out.println is used to print the properties of the system by calling properties.getProperty( key).

GetPropertyByName.java

import java.util.*;

public class GetPropertyByName {

    public static void main(String args[]) {

        Properties properties = System.getProperties();
        Set set = properties.stringPropertyNames();
        Iterator iterator = set.iterator();

        String key;
        while (iterator.hasNext()) {
            key = iterator.next().toString();

            System.out.print(key + " : ");
            System.out.println(properties.getProperty(key));
        }
    }
}

Output
java.runtime.name : Java(TM) SE Runtime Environment
sun.boot.library.path : C:\Program Files\Java\jdk1.6.0_01\jre\bin
java.vm.version : 1.6.0_01-b06
java.vm.vendor : Sun Microsystems Inc.
java.vendor.url : http://java.sun.com/
path.separator : ;
java.vm.name : Java HotSpot(TM) Client VM
file.encoding.pkg : sun.io
user.country : SUN_STANDARD
sun.java.launcher : US
sun.os.patch.level : Service Pack 4
java.vm.specification.name : Java Virtual Machine Specification
user.dir : C:\Documents and Settings\Administrator\
My Documents\NetBeansProjects\GetExample
java.runtime.version : 1.6.0_01-b06
java.awt.graphicsenv : sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs : C:\Program Files\Java\jdk1.6.0_01\jre\lib\endorsed
os.arch : x86
java.io.tmpdir : C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
line.separator :  
java.vm.specification.vendor : Sun Microsystems Inc.
user.variant :  
os.name : Windows 2000
sun.jnu.encoding : Cp1252
java.library.path : C:\ProgramFiles\Java\jdk1.6.0_01\jre\bin;
.;
C:\WINNT\Sun\Java\bin;C:\WINNT\system32;
C:\WINNT;.;C:\Program Files\Java\jdk1.6.0_01\bin;
C:\maven-2.0.7\bin;
C:\Program Files\Apache Software
Foundation\Tomcat 6.0\bin;
C:\Program Files\apache-ant-1.7.1\bin;
C:\GNUstep\GNUstep\System\Library\
Headers\Foundation;
C:\baadshah\GNUstep\mingw\bin;
C:\baadshah\GNUstep\GNUstep\System\Tools
java.specification.name : Java Platform API Specification
java.class.version : 50.0
sun.management.compiler : HotSpot Client Compiler
os.version : 5.0
user.home : C:\Documents and Settings\Administrator
user.timezone :  
java.awt.printerjob : sun.awt.windows.WPrinterJob
file.encoding : Cp1252
java.specification.version : 1.6
user.name :

C:\Documents and Settings\Administrator\
My Documents\NetBeansProjects\
GetExample\build\classes

java.class.path : Administrator
java.vm.specification.version : 1.0
sun.arch.data.model : C:\Program Files\Java\jdk1.6.0_01\jre
java.home : 32
java.specification.vendor : en
user.language : Sun Microsystems Inc.
awt.toolkit : sun.awt.windows.WToolkit
java.vm.info : mixed mode, sharing
java.version : 1.6.0_01
java.ext.dir :

C:\Program Files\Java\jdk1.6.0_01\jre\lib\ext;
C:\WINNT\Sun\Java\lib\ext

sun.boot.class.path :

C:\Program Files\Java\
jdk1.6.0_01\jre\lib\resources.jar;

C:\Program Files\Java\
jdk1.6.0_01\jre\lib\rt.jar;

C:\Program Files\Java\
jdk1.6.0_01\jre\lib\sunrsasign.jar;

C:\Program Files\Java\
jdk1.6.0_01\jre\lib\jsse.jar;

C:\Program Files\Java\
jdk1.6.0_01\jre\lib\jce.jar;

C:\Program Files\Java\
jdk1.6.0_01\jre\lib\charsets.jar;

C:\Program Files\Java\
jdk1.6.0_01\jre\classes

java.vendor : Sun Microsystems Inc.
file.separator : \
java.vendor.url.bug : http://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian : UnicodeLittle
sun.io.unicode.encoding : little
sun.desktop : windows
sun.cpu.isalist :  
 

Download code

                         

» View all related tutorials
Related Tags: java c memory time application object io runtime free method get order return this sso ai app with to run

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.