Consultor Eletrônico



Kbase 19567: Java Example to obtain & modify System properties
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/6/2000

Author: Enrique Birlanga
Creation Date: EBI 6-Mar-2000
Modified Date:

Version and Release Number: JDK 1.1.x & JDK 1.2.


INTRODUCTION:
=============

The attach java program can help you to find out what your system properties are and modify them as you need. This example can help you triagged out problems regarding settings in your system that affect java applications such as the java components on Progress V9.


PROGRAM:
========

// This example should be saved as Propiedades.java

import java.io.*;
import java.lang.*;

import java.util.*;
import java.text.*;

public class Propiedades
{
public static void main(String arg[])
{
Properties MyProp = new Properties();
Properties SysProp = System.getProperties();

Enumeration enumList = SysProp.propertyNames();

/** Display the original properties */
System.getProperties().list(System.out);

/** Load the default properties into my new properties object */
while (enumList.hasMoreElements()) {
Object myObj = enumList.nextElement();

MyProp.put(myObj, System.getProperty( (String) myObj ));
}

/** Update the properties that you need */

MyProp.put("user.language", "nl");
MyProp.put("user.region", "US");
MyProp.put("user.timezone", "EST");

/** Set the new properties in the system */
System.setProperties(MyProp);

/** Display the new properties */
System.getProperties().list(System.out);
}

} /* End of class Propiedades */


REFERENCES TO WRITTEN DOCUMENTATION:
Any Java book.

This example is only a reference to how it could be done. If you have any question regarding the code, please refer to any java documentation.

Progress Software Technical Support Note # 19567