// StatusProperties - display the system properties of the Java virtual machine // // Copyright (C)1996,1998 by Jef Poskanzer . All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. import java.applet.*; import java.awt.*; import java.io.*; import java.util.*; public class StatusProperties extends Applet { // Applet info. public String getAppletInfo() { return getClass().getName() + " - Copyright (C) 1996 by Jef Poskanzer . All rights reserved."; } TextArea textArea; // Called when the applet is first created. public void init() { Acme.GuiUtils.handleBgcolor( this ); setLayout( new BorderLayout() ); textArea = new TextArea(); textArea.setEditable( false ); add( "Center", textArea ); validate(); Enumeration names = getNames(); textArea.setText( "" ); while ( names.hasMoreElements() ) { String name = (String) names.nextElement(); tryProp( name ); if ( ! name.endsWith( ".applet" ) ) tryProp( name + ".applet" ); } } private Enumeration getNames() { try { Properties props = System.getProperties(); return props.propertyNames(); } catch ( SecurityException e ) { // If we can't read the list of properties, use a default list. return new StringTokenizer( "awt.appletWarning " + "awt.toolkit " + "browser " + "browser.vendor " + "browser.vendor.url " + "browser.version " + "file.encoding " + "file.encoding.pkg " + "file.separator " + "java.class.path " + "java.class.version " + "java.home " + "java.vendor " + "java.vendor.url " + "java.version " + "line.separator " + "os.arch " + "os.name " + "os.version " + "package.restrict.definition.java " + "package.restrict.definition.netscape " + "package.restrict.definition.sun " + "path.separator " + "trustProxy " + "user.dir " + "user.home " + "user.language " + "user.name " + "user.timezone " + "" ); } } private void tryProp( String name ) { try { String value = System.getProperty( name ); if ( value != null ) textArea.appendText( name + ": " + value + "\n" ); // textArea.append( name + ": " + value + "\n" ); } catch ( SecurityException ignore ) {} } // Main program, so we can run as an application too. public static void main( String[] args ) { new Acme.MainFrame( new StatusProperties(), args, 400, 500 ); } }