/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Non, Inc. 1998 -- All Rights Reserved
PACKAGE: net.non.applets
FILE: PropertyLister.java
AUTHOR: John D. Mitchell, Apr 28, 1998
REVISION HISTORY:
Name Date Description
---- ---- -----------
JDM 98.04.28 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
package net.non.applets;
// Standard Java Core packages:
import java.io.* ;
import java.lang.* ;
import java.net.* ;
import java.util.* ;
import java.applet.* ;
import java.awt.* ;
/**
** This example applet just prints out all of the system properties
** available to the applet.
**
** @author John D. Mitchell, Non, Inc., Apr 28, 1998
**
** @version 0.5
**
**/
public class PropertyLister extends Applet
{
private TextArea textArea = new TextArea (20, 70);
private String key = null;
private String value = null;
public void init()
{
add ("Center", textArea);
try
{
// Alas, rather than doing something intelligent when trying
// to foil crackers and other nefarious folks, the following
// will likely trigger a security exception if your applet
// is running in a restricted environment (like a browser).
try
{
Properties props = System.getProperties();
Enumeration e = props.propertyNames();
while (e.hasMoreElements())
{
key = (String) e.nextElement();
value = props.getProperty (key);
textArea.appendText ("Key :" + key +
": = :" + value + ":\n");
}
}
catch (SecurityException se)
{
// Oh well, no access to everything.
// The following list of properties are generally
// available in any context.
String keys [] =
{
"java.vendor", "java.vendor.url",
"java.version", "java.class.version",
"os.name", "os.arch", "os.version",
"file.separator", "path.separator",
"line.separator", "browser",
"browser.vendor", "browser.version"
};
for (int i = 0; i < keys.length; i++)
{
try
{
key = keys[i];
value = System.getProperty (key);
textArea.appendText ("Key :" + key +
": = :" + value + ":\n");
}
catch (SecurityException see) { ; }
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}